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 25, 2026 13:24Kevin HeaveyKevin HeaveyScore: 2,374Success
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 25, 2026 17:51Andrew Epstein14.40CustomSolution Held
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 25, 2026 13:302,35330,185,65713,021,0008,397,00092,778,496
2Sep 25, 2026 13:302,35729,997,76213,017,0008,439,00092,733,440
3Sep 25, 2026 13:302,36230,249,50913,092,0008,404,00092,721,152
4Sep 25, 2026 13:302,36730,246,59413,088,0008,454,00092,766,208
5Sep 25, 2026 13:302,37430,533,07413,130,0008,475,00092,753,920
6Sep 25, 2026 13:302,37730,313,11013,094,0008,538,00092,745,728
7Sep 25, 2026 13:302,37830,373,78913,121,0008,527,00092,758,016
8Sep 25, 2026 13:302,38230,443,23513,151,0008,533,00092,766,208
9Sep 25, 2026 13:302,38730,479,66613,232,0008,491,00092,741,632