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 4, 2026 02:07olliecrowolliecrowScore: 11,308Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 02:0711,212126,428,64484,026,00018,005,00094,572,544
2Mar 4, 2026 02:0711,275126,380,15984,676,00017,931,00094,560,256
3Mar 4, 2026 02:0711,303125,652,67284,879,00017,974,00094,552,064
4Mar 4, 2026 02:0711,305126,892,87085,894,00016,979,00094,564,352
5Mar 4, 2026 02:0711,308125,602,59887,919,00014,986,00094,556,160
6Mar 4, 2026 02:0711,313132,019,68783,957,00018,990,00094,556,160
7Mar 4, 2026 02:0711,316131,339,64786,983,00015,996,00094,547,968
8Mar 4, 2026 02:0711,326129,238,51687,055,00016,010,00094,556,160
9Mar 4, 2026 02:0711,327135,138,11788,209,00014,866,00094,658,560