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 03:18Andrew TsibinAndrew TsibinScore: 5,694Success
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 03:245,65561,565,26934,783,00016,686,00094,392,320
2Jul 30, 2026 03:245,65870,937,32534,822,00016,669,00094,392,320
3Jul 30, 2026 03:245,66762,192,40034,865,00016,708,00094,392,320
4Jul 30, 2026 03:245,68461,797,64134,996,00016,736,00094,392,320
5Jul 30, 2026 03:245,69473,559,97434,778,00017,044,00094,392,320
6Jul 30, 2026 03:245,70161,935,32134,940,00016,947,00094,392,320
7Jul 30, 2026 03:246,04765,089,88434,641,00020,393,00092,872,704
8Jul 30, 2026 03:246,15266,063,59834,649,00021,336,00092,864,512
9Jul 30, 2026 03:246,24066,949,99034,671,00022,121,00092,987,392