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 27, 2026 04:32olliecrowolliecrowScore: 6,104Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 27, 2026 04:356,04663,339,38135,015,00020,008,00094,650,368
2Apr 27, 2026 04:356,06763,527,98936,142,00019,075,00094,654,464
3Apr 27, 2026 04:356,08563,685,58537,252,00018,122,00094,633,984
4Apr 27, 2026 04:356,09463,883,26136,302,00019,159,00094,642,176
5Apr 27, 2026 04:356,10463,856,89639,393,00016,161,00094,654,464
6Apr 27, 2026 04:356,11964,065,24439,776,00015,910,00094,752,768
7Apr 27, 2026 04:356,13664,122,40735,900,00019,944,00094,834,688
8Apr 27, 2026 04:356,17163,734,90535,100,00021,060,00094,654,464
9Apr 27, 2026 04:356,17963,517,48934,140,00022,090,00094,633,984