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 listApr 22, 2026 21:11Dominique GarmierDominique GarmierScore: 8,945Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 21:138,888104,734,25228,959,00051,928,00094,769,152
2Apr 22, 2026 21:138,90093,836,96434,997,00045,996,00094,580,736
3Apr 22, 2026 21:138,91496,996,32634,051,00047,070,00094,756,864
4Apr 22, 2026 21:138,92598,813,20831,085,00050,137,00094,838,784
5Apr 22, 2026 21:138,94597,848,31033,165,00048,240,00094,728,192
6Apr 22, 2026 21:138,990101,810,92527,937,00053,879,00094,781,440
7Apr 22, 2026 21:139,05999,979,55728,150,00054,290,00094,801,920
8Apr 22, 2026 21:139,062105,848,76729,167,00053,306,00094,769,152
9Apr 22, 2026 21:139,062103,946,02236,205,00046,262,00094,588,928