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 listMay 3, 2026 16:56TudyMTudyMScore: 8,582Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 17:058,57292,533,88861,389,00016,619,00094,633,984
2May 3, 2026 17:058,57592,873,04161,301,00016,738,00094,646,272
3May 3, 2026 17:058,57593,597,78260,747,00017,294,00094,633,984
4May 3, 2026 17:058,57893,442,27761,169,00016,899,00094,638,080
5May 3, 2026 17:058,58294,750,18160,816,00017,284,00094,625,792
6May 3, 2026 17:058,58393,129,12960,601,00017,509,00094,638,080
7May 3, 2026 17:058,58893,758,19860,771,00017,382,00094,646,272
8May 3, 2026 17:058,61393,941,00561,696,00016,691,00094,638,080
9May 3, 2026 17:058,61895,836,55360,976,00017,448,00094,633,984