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:04Andrew TsibinAndrew TsibinScore: 5,698Success
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:095,68762,626,02829,420,00022,336,00092,954,624
2Jul 30, 2026 03:095,69562,709,73129,342,00022,489,00092,938,240
3Jul 30, 2026 03:095,69762,642,63529,801,00022,043,00092,999,680
4Jul 30, 2026 03:095,69861,979,00229,344,00022,508,00092,901,376
5Jul 30, 2026 03:095,69862,020,34329,231,00022,623,00092,942,336
6Jul 30, 2026 03:095,70061,985,33529,850,00022,020,00092,958,720
7Jul 30, 2026 03:095,70762,086,67229,420,00022,517,00092,950,528
8Jul 30, 2026 03:095,79962,914,08729,268,00023,508,00092,934,144
9Jul 30, 2026 03:095,92764,090,07329,682,00024,262,00092,901,376