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 listSep 15, 2026 00:07Andrew EpsteinAndrew EpsteinScore: 49,404Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 00:1349,229458,346,970316,614,000131,370,00092,684,288stderr
2Sep 15, 2026 00:1349,253458,599,716317,186,000131,019,00092,721,152stderr
3Sep 15, 2026 00:1349,312459,101,129317,388,000131,360,00092,737,536stderr
4Sep 15, 2026 00:1349,355459,841,697317,542,000131,596,00092,782,592stderr
5Sep 15, 2026 00:1349,404459,866,737317,904,000131,681,00092,749,824stderr
6Sep 15, 2026 00:1349,424460,079,602317,813,000131,949,00092,745,728stderr
7Sep 15, 2026 00:1349,653462,219,765318,872,000132,979,00092,733,440stderr
8Sep 15, 2026 00:1349,703462,926,867318,982,000133,318,00092,774,400stderr
9Sep 15, 2026 00:1349,705462,832,120319,299,000133,021,00092,745,728stderr