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 listJun 5, 2026 16:43Victor MerckléVictor MerckléScore: 2,859Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 16:492,84034,886,67817,167,0008,678,00092,737,536
2Jun 5, 2026 16:492,84235,000,48117,327,0008,544,00092,745,728
3Jun 5, 2026 16:492,84434,925,88617,192,0008,695,00092,766,208
4Jun 5, 2026 16:492,85835,053,28617,400,0008,611,00092,733,440
5Jun 5, 2026 16:492,85935,072,60317,423,0008,594,00092,680,192
6Jun 5, 2026 16:492,86235,153,55517,439,0008,606,00092,745,728
7Jun 5, 2026 16:492,86835,150,19617,420,0008,679,00092,790,784
8Jun 5, 2026 16:492,86835,211,99417,432,0008,667,00092,815,360
9Jun 5, 2026 16:492,87435,248,90517,365,0008,794,00092,737,536