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 30, 2026 04:04olliecrowolliecrowScore: 5,293Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 30, 2026 04:055,25065,640,05423,891,00023,891,00094,806,016
2Apr 30, 2026 04:055,25764,060,61928,907,00018,939,00094,613,504
3Apr 30, 2026 04:055,25765,856,73825,914,00021,928,00094,601,216
4Apr 30, 2026 04:055,29168,412,66831,099,00017,054,00094,797,824
5Apr 30, 2026 04:055,29365,787,91733,115,00015,052,00094,613,504
6Apr 30, 2026 04:055,30469,530,66530,169,00018,101,00094,806,016
7Apr 30, 2026 04:055,31164,152,42927,189,00021,147,00094,613,504
8Apr 30, 2026 04:055,33066,111,99532,670,00015,840,00094,801,920
9Apr 30, 2026 04:055,34871,204,75729,800,00018,873,00094,801,920