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 25, 2026 04:31Dominique GarmierDominique GarmierScore: 38,258Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 22, 2026 19:2738,176375,936,432325,439,00021,962,00094,789,632
2Mar 22, 2026 16:0438,198381,368,381324,625,00022,973,00094,666,752
3Mar 25, 2026 04:3138,210377,889,216325,726,00021,981,00094,801,920
4Mar 22, 2026 19:2738,226374,757,149325,866,00021,990,00094,801,920
5Mar 22, 2026 19:5738,226377,201,114326,864,00020,991,00094,806,016
6Mar 22, 2026 19:5738,227368,095,618324,876,00022,991,00094,629,888
7Mar 22, 2026 16:0438,258369,841,103327,140,00021,009,00094,806,016
8Mar 22, 2026 16:0438,285379,356,512325,432,00022,959,00094,642,176
9Mar 25, 2026 04:3138,305375,237,550325,608,00022,972,00094,625,792
10Mar 22, 2026 19:5738,368379,239,136328,138,00021,008,00094,810,112
11Mar 22, 2026 19:2738,476381,543,888322,199,00027,930,00094,633,984
12Mar 25, 2026 04:3138,476377,918,773324,198,00025,935,00094,646,272