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 19, 2026 12:56Victor MerckléVictor MerckléScore: 2,590Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 13:012,57632,406,28814,786,0008,663,00092,766,208stderr
2Aug 19, 2026 13:012,57631,810,42314,980,0008,470,00092,774,400stderr
3Aug 19, 2026 13:012,58131,970,66614,802,0008,688,00092,782,592stderr
4Aug 19, 2026 13:012,58332,499,62114,928,0008,578,00092,766,208stderr
5Aug 19, 2026 13:012,59032,660,87415,038,0008,538,00092,704,768stderr
6Aug 19, 2026 13:012,59031,894,90114,668,0008,903,00092,737,536stderr
7Aug 19, 2026 13:012,59132,698,86914,920,0008,666,00092,753,920stderr
8Aug 19, 2026 13:012,60632,735,64314,932,0008,788,00092,758,016stderr
9Aug 19, 2026 13:012,60932,785,30114,946,0008,801,00092,778,496stderr