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 TsibinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 11, 2026 00:41Andrew Epstein57.31CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 11, 2026 00:420320,837,949287,188,00023,498,000134,238,208invalid character '.' looking for beginning of value
2Sep 11, 2026 00:420321,033,392287,455,00023,404,000134,238,208invalid character '.' looking for beginning of value
3Sep 11, 2026 00:420320,899,533287,244,00023,415,000134,238,208invalid character '.' looking for beginning of value
4Jul 30, 2026 00:535,57361,019,81734,112,00016,610,00094,392,320
5Jul 30, 2026 00:535,59861,255,49634,069,00016,879,00094,392,320
6Jul 30, 2026 00:535,60661,892,05234,150,00016,867,00094,392,320
7Jul 30, 2026 00:535,61161,249,42334,114,00016,952,00094,392,320
8Jul 30, 2026 00:535,61263,341,18734,117,00016,953,00094,392,320
9Jul 30, 2026 00:535,62862,030,21434,255,00016,964,00094,392,320
10Jul 30, 2026 00:536,03265,181,91233,428,00021,472,00092,876,800
11Jul 30, 2026 00:536,18967,148,30633,572,00022,751,00092,876,800
12Jul 30, 2026 00:536,20066,472,45233,386,00023,038,00092,966,912