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 11, 2026 16:55Victor MerckléVictor MerckléScore: 2,738Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 17:012,72033,803,39816,045,0008,708,00092,770,304
2Jun 11, 2026 17:012,72033,794,18316,044,0008,710,00092,733,440
3Jun 11, 2026 17:012,72133,822,89616,028,0008,742,00092,729,344
4Jun 11, 2026 17:012,73233,892,80316,085,0008,784,00092,778,496
5Jun 11, 2026 17:012,73833,966,58816,124,0008,795,00092,749,824
6Jun 11, 2026 17:012,74834,005,69916,152,0008,859,00092,782,592
7Jun 11, 2026 17:012,75034,045,83316,449,0008,578,00092,753,920
8Jun 11, 2026 17:012,75334,104,11016,157,0008,897,00092,770,304
9Jun 11, 2026 17:012,75834,072,84816,196,0008,910,00092,692,480