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 listMay 5, 2026 01:36olliecrowolliecrowScore: 4,308Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 01:414,29653,384,45621,492,00017,607,00094,793,728
2May 5, 2026 01:414,29755,644,82121,505,00017,604,00094,806,016
3May 5, 2026 01:414,29859,533,01221,616,00017,499,00094,801,920
4May 5, 2026 01:414,30059,146,38121,744,00017,389,00094,801,920
5May 5, 2026 01:414,30856,065,09321,534,00017,673,00094,806,016
6May 5, 2026 01:414,30953,127,30021,749,00017,464,00094,797,824
7May 5, 2026 01:414,31656,434,19321,665,00017,616,00094,793,728
8May 5, 2026 01:414,32056,128,69821,807,00017,513,00094,801,920
9May 5, 2026 01:414,33058,686,08821,763,00017,642,00094,793,728