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:58Andrew TsibinAndrew TsibinScore: 5,806Success
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 02:035,32659,436,15631,150,00017,324,00094,392,320
2Jul 30, 2026 02:035,42559,533,38230,813,00018,563,00092,852,224
3Jul 30, 2026 02:035,55360,717,35630,489,00020,050,00092,807,168
4Jul 30, 2026 02:035,70862,006,53830,373,00021,573,00092,856,320
5Jul 30, 2026 02:035,80662,972,45030,732,00022,106,00092,995,584
6Jul 30, 2026 02:035,80962,995,61830,216,00022,650,00092,962,816
7Jul 30, 2026 02:035,83263,225,08930,298,00022,778,00092,934,144
8Jul 30, 2026 02:035,83663,240,83130,256,00022,859,00092,893,184
9Jul 30, 2026 02:036,10366,401,32430,291,00025,251,00092,893,184