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 23:03olliecrowolliecrowScore: 4,469Success
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 23:094,44256,541,13023,844,00016,581,00094,756,864
2May 5, 2026 23:094,45355,355,21623,866,00016,665,00094,765,056
3May 5, 2026 23:094,45857,267,74023,901,00016,672,00094,765,056
4May 5, 2026 23:094,46455,523,78323,889,00016,736,00094,756,864
5May 5, 2026 23:094,46958,032,00123,832,00016,836,00094,760,960
6May 5, 2026 23:094,47055,306,35323,918,00016,766,00094,744,576
7May 5, 2026 23:094,49353,889,66223,402,00017,489,00094,765,056
8May 5, 2026 23:094,49458,959,15223,429,00017,467,00094,760,960
9May 5, 2026 23:094,49557,229,04723,890,00017,015,00094,756,864