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 listAug 16, 2026 07:08marko1597marko1597Score: 3,472Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 07:143,46139,919,30323,206,0008,290,00092,762,112stderr
2Aug 16, 2026 07:143,46439,867,52323,195,0008,328,00092,766,208stderr
3Aug 16, 2026 07:143,47039,919,80823,209,0008,375,00092,774,400stderr
4Aug 16, 2026 07:143,47140,666,22923,222,0008,373,00092,684,288stderr
5Aug 16, 2026 07:143,47240,679,62423,230,0008,366,00092,749,824stderr
6Aug 16, 2026 07:143,48640,121,58323,262,0008,465,00092,655,616stderr
7Aug 16, 2026 07:143,49140,122,99523,301,0008,476,00092,819,456stderr
8Aug 16, 2026 07:143,49240,170,24423,510,0008,276,00092,770,304stderr
9Aug 16, 2026 07:143,49440,167,31723,332,0008,470,00092,790,784stderr