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 15, 2026 22:59marko1597marko1597Score: 3,541Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 23:233,51540,354,08823,678,0008,312,00092,704,768stderr
2Aug 15, 2026 23:233,52140,646,52423,712,0008,334,00092,700,672stderr
3Aug 15, 2026 23:233,53040,478,31323,739,0008,389,00092,807,168stderr
4Aug 15, 2026 23:233,53240,495,06523,761,0008,386,00092,749,824stderr
5Aug 15, 2026 23:233,54140,668,99823,903,0008,328,00092,737,536stderr
6Aug 15, 2026 23:233,54440,649,02723,865,0008,390,00092,733,440stderr
7Aug 15, 2026 23:233,55940,799,56323,947,0008,442,00092,745,728stderr
8Aug 15, 2026 23:233,56941,552,32423,993,0008,490,00092,770,304stderr
9Aug 15, 2026 23:233,62041,270,91024,492,0008,459,00092,721,152stderr