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 listApr 20, 2026 23:16olliecrowolliecrowScore: 4,235Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2026 23:184,19160,554,84721,080,00017,064,00094,523,392
2Apr 20, 2026 23:184,20060,830,25321,123,00017,099,00094,523,392
3Apr 20, 2026 23:184,20360,668,93220,134,00018,120,00094,773,248
4Apr 20, 2026 23:184,22061,645,63122,234,00016,170,00094,556,160
5Apr 20, 2026 23:184,23563,161,38722,317,00016,230,00094,781,440
6Apr 20, 2026 23:184,23963,378,21822,750,00015,826,00094,527,488
7Apr 20, 2026 23:184,24764,559,09723,788,00014,867,00094,556,160
8Apr 20, 2026 23:184,25164,464,22821,826,00016,866,00094,523,392
9Apr 20, 2026 23:184,25669,614,68320,858,00017,878,00094,523,392