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 01:48Andrew TsibinAndrew TsibinScore: 22,097Success
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 01:5321,580206,404,198180,020,00016,359,00094,392,320
2Jul 30, 2026 01:5321,616206,751,410179,296,00017,413,00092,766,208
3Jul 30, 2026 01:5321,759209,022,886180,262,00017,751,00094,392,320
4Jul 30, 2026 01:5321,806208,545,168178,858,00019,577,00092,807,168
5Jul 30, 2026 01:5322,097211,186,748178,621,00022,464,00092,983,296
6Jul 30, 2026 01:5322,129211,454,466179,018,00022,360,00092,930,048
7Jul 30, 2026 01:5322,143211,617,808178,916,00022,588,00092,934,144
8Jul 30, 2026 01:5322,147211,702,344179,081,00022,460,00092,995,584
9Jul 30, 2026 01:5322,287212,967,848178,817,00023,995,00092,954,624