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 listAug 18, 2026 15:00Victor MerckléVictor MerckléScore: 2,768Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 18, 2026 15:052,76134,975,12416,349,0008,783,00092,741,632stderr
2Aug 18, 2026 15:052,76535,056,46716,398,0008,772,00092,811,264stderr
3Aug 18, 2026 15:052,76535,055,06416,390,0008,774,00092,770,304stderr
4Aug 18, 2026 15:052,76735,022,95016,383,0008,799,00092,807,168stderr
5Aug 18, 2026 15:052,76835,004,41316,390,0008,803,00092,712,960stderr
6Aug 18, 2026 15:052,77242,176,61116,639,0008,591,00092,712,960stderr
7Aug 18, 2026 15:052,79735,263,62216,625,0008,829,00092,745,728stderr
8Aug 18, 2026 15:052,80035,246,14916,669,0008,811,00092,753,920stderr
9Aug 18, 2026 15:052,80735,366,88116,743,0008,805,00092,692,480stderr