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 listMay 6, 2026 11:00olliecrowolliecrowScore: 4,135Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 6, 2026 11:064,12155,796,94920,871,00016,635,00092,569,600
2May 6, 2026 11:064,12754,314,32720,916,00016,641,00092,565,504
3May 6, 2026 11:064,13254,948,93120,923,00016,685,00092,549,120
4May 6, 2026 11:064,13554,872,91320,889,00016,740,00092,569,600
5May 6, 2026 11:064,13554,755,09820,859,00016,770,00092,565,504
6May 6, 2026 11:064,14653,891,80420,916,00016,815,00092,565,504
7May 6, 2026 11:064,16754,916,68121,069,00016,853,00092,569,600
8May 6, 2026 11:064,17256,471,28621,106,00016,861,00092,569,600
9May 6, 2026 11:064,18756,305,71520,600,00017,510,00092,561,408