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 15, 2026 00:16Andrew EpsteinAndrew EpsteinScore: 3,259Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 00:223,24639,811,13421,078,0008,463,00092,729,344
2Sep 15, 2026 00:223,25139,881,59721,092,0008,499,00092,770,304
3Sep 15, 2026 00:223,25239,876,77820,959,0008,639,00092,762,112
4Sep 15, 2026 00:223,25339,965,49821,111,0008,498,00092,745,728
5Sep 15, 2026 00:223,25940,719,86821,105,0008,559,00092,758,016
6Sep 15, 2026 00:223,26440,114,00221,052,0008,654,00092,733,440
7Sep 15, 2026 00:223,26940,232,30421,170,0008,583,00092,733,440
8Sep 15, 2026 00:223,27940,179,02621,211,0008,635,00092,758,016
9Sep 15, 2026 00:223,28741,481,51521,164,0008,748,00092,741,632