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 listSep 14, 2026 02:11Andrew EpsteinAndrew EpsteinScore: 4,035Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 02:174,01946,757,00827,997,0008,580,00092,753,920
2Sep 14, 2026 02:174,02446,955,20128,042,0008,582,00092,721,152
3Sep 14, 2026 02:174,02747,026,52828,031,0008,622,00092,753,920
4Sep 14, 2026 02:174,03349,090,10828,077,0008,627,00092,708,864
5Sep 14, 2026 02:174,03547,789,40028,100,0008,625,00092,794,880
6Sep 14, 2026 02:174,04347,058,37628,124,0008,673,00092,762,112
7Sep 14, 2026 02:174,05347,964,92928,113,0008,774,00092,786,688
8Sep 14, 2026 02:174,05547,976,48628,133,0008,773,00092,778,496
9Sep 14, 2026 02:174,06147,419,16728,189,0008,773,00092,696,576