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 23, 2026 02:04olliecrowolliecrowScore: 6,385Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2026 02:086,32975,240,18641,708,00015,889,00094,834,688
2Apr 23, 2026 02:086,35166,220,68134,880,00022,921,00094,633,984
3Apr 23, 2026 02:086,35776,530,16332,915,00024,936,00094,842,880
4Apr 23, 2026 02:086,38474,609,37342,074,00016,028,00094,584,832
5Apr 23, 2026 02:086,38566,304,38936,069,00022,042,00094,851,072
6Apr 23, 2026 02:086,39266,587,00440,122,00018,054,00094,654,464
7Apr 23, 2026 02:086,39578,660,09837,125,00021,071,00094,597,120
8Apr 23, 2026 02:086,44166,213,11743,715,00014,902,00094,650,368
9Apr 23, 2026 02:086,51977,732,75241,230,00018,101,00094,588,928