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 listApr 28, 2026 10:16TudyMTudyMScore: 14,651Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 10:2014,610151,986,274111,959,00020,992,00094,629,888
2Apr 28, 2026 10:2014,617150,383,152112,016,00021,003,00094,629,888
3Apr 28, 2026 10:2014,635162,585,232112,154,00021,028,00094,629,888
4Apr 28, 2026 10:2014,638152,577,514112,178,00021,033,00094,597,120
5Apr 28, 2026 10:2014,651151,543,298111,437,00021,889,00094,810,112
6Apr 28, 2026 10:2014,663155,822,427111,528,00021,907,00094,621,696
7Apr 28, 2026 10:2014,691155,328,947110,747,00022,947,00094,633,984
8Apr 28, 2026 10:2014,710150,624,489110,888,00022,976,00094,601,216
9Apr 28, 2026 10:2014,878158,203,918125,437,0009,955,00094,638,080