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 listSep 16, 2026 16:03Victor MerckléVictor MerckléScore: 2,694Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 16:082,67835,226,21015,734,0008,642,00092,774,400stderr
2Sep 16, 2026 16:082,68233,142,70515,751,0008,660,00092,700,672stderr
3Sep 16, 2026 16:082,69033,224,23015,791,0008,692,00092,729,344stderr
4Sep 16, 2026 16:082,69233,225,42815,809,0008,690,00092,766,208stderr
5Sep 16, 2026 16:082,69433,330,73315,776,0008,741,00092,688,384stderr
6Sep 16, 2026 16:082,69533,334,62815,783,0008,743,00092,766,208stderr
7Sep 16, 2026 16:082,69533,965,73515,793,0008,734,00092,737,536stderr
8Sep 16, 2026 16:082,70134,050,63915,772,0008,814,00092,770,304stderr
9Sep 16, 2026 16:082,70733,404,90115,796,0008,838,00092,762,112stderr