XML to JSON Sergey Svistunov

Convert 1,000,000 person records from XML to JSON as fast as possible.

Input

XML document on STDIN:

<?xml version="1.0" encoding="UTF-8"?>
<persons>
    <person id="1512376">
        <age>30</age>
        <height>169.1</height>
        <married>true</married>
        <phone code="+6"><number>1283603279</number></phone>
        <phone code="+6"><number>1659964668</number></phone>
    </person>
    ...
</persons>

Output

One JSON object per person to STDOUT, preserving order:

{
    "id": 1512376,
    "age": 30,
    "height": 169.1,
    "married": true,
    "phones": [
        {
            "code": "+6",
            "number": 1283603279
        },
        {
            "code": "+6",
            "number": 1659964668
        }
    ]
}

Constraints

  • Preserve the order of persons
  • Omit the phones field if the phone array is empty
  • Maximum number of phones per person is 3
Back to listNov 3, 2026 05:17Andrew EpsteinAndrew EpsteinScore: 2,540Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 05:342,52633,796,67914,181,0008,809,00092,741,632
2Nov 3, 2026 05:342,53433,917,30214,235,0008,825,00092,741,632
3Nov 3, 2026 05:342,53834,444,72814,281,0008,822,00092,807,168
4Nov 3, 2026 05:342,54033,931,84114,245,0008,873,00092,753,920
5Nov 3, 2026 05:342,54034,137,98914,324,0008,797,00092,712,960
6Nov 3, 2026 05:342,54134,075,79614,271,0008,857,00092,700,672
7Nov 3, 2026 05:342,54934,195,55914,292,0008,904,00092,741,632
8Nov 3, 2026 05:342,55034,030,98614,362,0008,846,00092,749,824
9Nov 3, 2026 05:342,55934,725,18914,336,0008,953,00092,745,728