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 4, 2026 06:21Victor MerckléVictor MerckléScore: 3,161Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2026 06:263,14546,448,25619,984,0008,642,00093,028,352
2May 4, 2026 06:263,14646,661,13420,013,0008,619,00092,987,392
3May 4, 2026 06:263,15443,639,18720,053,0008,650,00093,007,872
4May 4, 2026 06:263,15844,925,67120,036,0008,710,00093,040,640
5May 4, 2026 06:263,16142,924,41720,046,0008,724,00092,979,200
6May 4, 2026 06:263,16244,907,30020,033,0008,749,00093,044,736
7May 4, 2026 06:263,17445,891,84220,060,0008,826,00092,991,488
8May 4, 2026 06:263,17445,362,24220,105,0008,786,00093,069,312
9May 4, 2026 06:263,18247,928,18720,094,0008,869,00093,020,160