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 02:12Andrew 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:185,77163,277,17230,430,00022,092,00092,954,624
2Jul 30, 2026 02:185,79962,808,34630,093,00022,684,00092,962,816
3Jul 30, 2026 02:185,80062,881,95330,210,00022,573,00092,893,184
4Jul 30, 2026 02:185,80162,876,94230,268,00022,530,00092,966,912
5Jul 30, 2026 02:185,80662,897,18030,386,00022,456,00092,905,472
6Jul 30, 2026 02:185,84263,267,13330,618,00022,553,00092,938,240
7Jul 30, 2026 02:185,97464,967,09130,592,00023,776,00092,979,200
8Jul 30, 2026 02:185,98664,584,60230,515,00023,964,00092,983,296
9Jul 30, 2026 02:186,04065,726,89430,485,00024,487,00092,979,200