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 09:34Victor MerckléVictor MerckléScore: 3,139Success
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 09:403,12038,387,55820,015,0008,384,00092,782,592stderr
2Sep 15, 2026 09:403,12937,163,61720,066,0008,414,00092,737,536stderr
3Sep 15, 2026 09:403,13437,903,34820,201,0008,321,00092,770,304stderr
4Sep 15, 2026 09:403,13537,253,86920,205,0008,328,00092,704,768stderr
5Sep 15, 2026 09:403,13937,945,81120,242,0008,329,00092,811,264stderr
6Sep 15, 2026 09:403,14037,955,47420,244,0008,332,00092,770,304stderr
7Sep 15, 2026 09:403,14137,456,36719,894,0008,692,00092,729,344stderr
8Sep 15, 2026 09:403,14638,034,25220,233,0008,396,00092,778,496stderr
9Sep 15, 2026 09:403,14837,950,16319,954,0008,699,00092,725,248stderr