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 20, 2026 00:21olliecrowolliecrowScore: 8,810Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 00:268,698105,154,84131,059,00048,092,00094,732,288
2Mar 20, 2026 00:248,711104,821,18841,139,00038,128,00094,728,192
3Mar 20, 2026 00:248,717107,210,68927,111,00052,213,00094,703,616
4Mar 20, 2026 00:268,740100,313,18326,842,00052,690,00094,695,424
5Mar 20, 2026 00:298,750107,425,82128,221,00051,403,00094,674,944
6Mar 20, 2026 00:268,778109,415,64131,953,00047,929,00094,674,944
7Mar 20, 2026 00:298,810107,541,41629,062,00051,109,00094,691,328
8Mar 20, 2026 00:218,811101,198,42228,064,00052,119,00094,720,000
9Mar 20, 2026 00:248,831103,839,39835,157,00045,203,00094,744,576
10Mar 20, 2026 00:298,881102,685,12027,938,00052,883,00094,564,352
11Mar 20, 2026 00:218,923109,105,45334,084,00047,116,00094,777,344
12Mar 20, 2026 00:218,928107,796,19334,102,00047,142,00094,687,232