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 22, 2026 05:27olliecrowolliecrowScore: 4,498Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 05:294,49060,255,79923,921,00016,944,00094,609,408
2Apr 22, 2026 05:294,49057,317,26724,917,00015,947,00094,625,792
3Apr 22, 2026 05:294,49257,405,20823,933,00016,953,00094,617,600
4Apr 22, 2026 05:294,49359,020,42423,935,00016,954,00094,609,408
5Apr 22, 2026 05:294,49857,634,05924,962,00015,976,00094,629,888
6Apr 22, 2026 05:294,49862,312,93422,965,00017,973,00094,629,888
7Apr 22, 2026 05:294,51058,473,07523,026,00018,020,00094,633,984
8Apr 22, 2026 05:294,52459,751,52825,105,00016,067,00094,625,792
9Apr 22, 2026 05:294,54858,865,10225,238,00016,152,00094,638,080