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 listJul 30, 2026 00:47Andrew TsibinAndrew TsibinScore: 5,612Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 30, 2026 00:535,57361,019,81734,112,00016,610,00094,392,320
2Jul 30, 2026 00:535,59861,255,49634,069,00016,879,00094,392,320
3Jul 30, 2026 00:535,60661,892,05234,150,00016,867,00094,392,320
4Jul 30, 2026 00:535,61161,249,42334,114,00016,952,00094,392,320
5Jul 30, 2026 00:535,61263,341,18734,117,00016,953,00094,392,320
6Jul 30, 2026 00:535,62862,030,21434,255,00016,964,00094,392,320
7Jul 30, 2026 00:536,03265,181,91233,428,00021,472,00092,876,800
8Jul 30, 2026 00:536,18967,148,30633,572,00022,751,00092,876,800
9Jul 30, 2026 00:536,20066,472,45233,386,00023,038,00092,966,912