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:09olliecrowolliecrowScore: 10,679Success
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:1110,602112,810,98575,381,00021,106,00094,752,768
2Apr 22, 2026 05:1110,610114,251,32578,639,00017,917,00094,765,056
3Apr 22, 2026 05:1110,643111,683,37277,886,00018,972,00094,666,752
4Apr 22, 2026 05:1110,659114,080,46476,000,00021,000,00094,765,056
5Apr 22, 2026 05:1110,679118,815,19581,152,00016,030,00094,756,864
6Apr 22, 2026 05:1110,703109,413,30687,363,00010,041,00094,760,960
7Apr 22, 2026 05:1110,711111,028,54182,248,00015,231,00094,752,768
8Apr 22, 2026 05:1110,714115,772,02782,427,00015,078,00094,756,864
9Apr 22, 2026 05:1110,733114,968,24882,570,00015,104,00094,609,408