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 listMar 21, 2026 04:13olliecrowolliecrowScore: 8,341Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 14:018,31196,894,46257,716,00017,911,00094,654,464
2Mar 21, 2026 04:138,317106,170,81460,744,00014,937,00094,806,016
3Mar 21, 2026 04:138,32396,393,32859,796,00015,945,00094,760,960
4Mar 20, 2026 14:018,326100,389,63656,826,00018,942,00094,756,864
5Mar 21, 2026 04:138,34197,885,10058,928,00016,979,00094,806,016
6Mar 21, 2026 04:138,37299,396,26358,144,00018,044,00094,748,672
7Mar 20, 2026 14:018,40596,387,23459,600,00016,886,00094,752,768
8Mar 21, 2026 04:138,489100,196,99662,202,00015,049,00094,806,016
9Mar 21, 2026 04:138,555106,749,66764,057,00013,796,00094,806,016