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 19, 2026 15:53Victor MerckléVictor MerckléScore: 2,508Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 16:002,48531,226,91613,696,0008,919,00092,815,360stderr
2Aug 19, 2026 16:002,50031,234,77313,611,0009,142,00092,811,264stderr
3Aug 19, 2026 16:002,50431,408,19413,739,0009,052,00092,798,976stderr
4Aug 19, 2026 16:002,50631,072,03113,799,0009,014,00092,815,360stderr
5Aug 19, 2026 16:002,50831,215,68113,914,0008,915,00092,819,456stderr
6Aug 19, 2026 16:002,53232,997,06714,190,0008,852,00092,835,840stderr
7Aug 19, 2026 16:002,53531,563,88514,221,0008,853,00092,823,552stderr
8Aug 19, 2026 16:002,53832,424,63014,047,0009,051,00092,737,536stderr
9Aug 19, 2026 16:002,54431,594,86614,217,0008,942,00092,803,072stderr