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 15, 2026 14:50Victor MerckléVictor MerckléScore: 3,140Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 15:043,13037,320,89520,107,0008,381,00092,745,728stderr
2Sep 15, 2026 15:043,13138,394,68720,098,0008,399,00092,753,920stderr
3Sep 15, 2026 15:043,13237,199,40519,808,0008,697,00092,700,672stderr
4Sep 15, 2026 15:043,13437,260,12320,090,0008,431,00092,770,304stderr
5Sep 15, 2026 15:043,14037,421,04120,280,0008,300,00092,745,728stderr
6Sep 15, 2026 15:043,14737,368,34720,129,0008,515,00092,725,248stderr
7Sep 15, 2026 15:043,14837,314,10319,984,0008,667,00092,700,672stderr
8Sep 15, 2026 15:043,15238,109,70920,299,0008,385,00092,737,536stderr
9Sep 15, 2026 15:043,16437,680,36220,449,0008,351,00092,774,400stderr