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 17:19TudyMTudyMScore: 8,544Success
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:248,49794,766,97960,845,00016,484,00094,650,368
2May 3, 2026 17:248,51091,595,10360,878,00016,566,00094,642,176
3May 3, 2026 17:248,52792,705,25860,913,00016,690,00094,625,792
4May 3, 2026 17:248,52793,512,74360,209,00017,387,00094,633,984
5May 3, 2026 17:248,54494,222,65060,251,00017,506,00094,625,792
6May 3, 2026 17:248,56894,616,57160,446,00017,530,00094,629,888
7May 3, 2026 17:248,57997,862,61460,453,00017,621,00094,629,888
8May 3, 2026 17:248,58192,403,19761,328,00016,763,00094,625,792
9May 3, 2026 17:248,63094,699,29361,808,00016,732,00094,642,176