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 listMar 10, 2026 16:22Josu San MartinJosu San MartinScore: 4,061Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 16:224,04570,299,95118,902,00017,907,00094,732,288
2Mar 10, 2026 16:224,05261,177,59416,942,00019,931,00094,674,944
3Mar 10, 2026 16:224,05759,910,67519,958,00016,964,00094,785,536
4Mar 10, 2026 16:224,05858,739,25117,965,00018,964,00094,552,064
5Mar 10, 2026 16:224,06158,779,30720,976,00015,981,00094,785,536
6Mar 10, 2026 16:224,06661,156,97719,003,00018,002,00094,547,968
7Mar 10, 2026 16:224,06860,703,65220,010,00017,009,00094,674,944
8Mar 10, 2026 16:224,08559,685,37718,083,00019,088,00094,552,064
9Mar 10, 2026 16:224,09366,537,36520,134,00017,114,00094,670,848