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 1, 2026 02:23Charles CabergsCharles CabergsScore: 4,051Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2026 02:254,02754,321,38318,818,00017,828,00094,617,600
2May 1, 2026 02:254,04253,879,25420,877,00015,906,00094,613,504
3May 1, 2026 02:254,04755,934,12819,907,00016,921,00094,810,112
4May 1, 2026 02:254,04855,664,46217,921,00018,917,00094,793,728
5May 1, 2026 02:254,05158,232,93417,934,00018,931,00094,777,344
6May 1, 2026 02:254,05553,851,87218,949,00017,952,00094,597,120
7May 1, 2026 02:254,06256,492,26818,982,00017,983,00094,810,112
8May 1, 2026 02:254,06660,359,34217,001,00020,002,00094,793,728
9May 1, 2026 02:254,09454,743,18118,126,00019,133,00094,789,632