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:53Andrew TsibinAndrew TsibinScore: 6,105Success
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:586,07165,297,55433,183,00022,069,00092,909,568
2Jul 30, 2026 02:586,09465,508,07132,827,00022,637,00092,983,296
3Jul 30, 2026 02:586,09665,650,90733,356,00022,119,00092,942,336
4Jul 30, 2026 02:586,09765,558,85532,864,00022,620,00092,905,472
5Jul 30, 2026 02:586,10567,121,22532,859,00022,702,00092,979,200
6Jul 30, 2026 02:586,21066,585,91433,105,00023,410,00092,971,008
7Jul 30, 2026 02:586,33967,764,00833,335,00024,356,00092,962,816
8Jul 30, 2026 02:586,34267,886,44233,210,00024,510,00092,983,296
9Jul 30, 2026 02:586,34567,927,26832,954,00024,786,00093,003,776