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 2, 2026 15:36Victor 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 2, 2026 15:412,75035,026,62016,296,0008,737,00092,782,592stderr
2Aug 2, 2026 15:412,75435,048,65816,286,0008,778,00092,692,480stderr
3Aug 2, 2026 15:412,75935,022,55816,341,0008,774,00092,704,768stderr
4Aug 2, 2026 15:412,76234,944,73716,346,0008,793,00092,712,960stderr
5Aug 2, 2026 15:412,76834,957,95216,398,0008,791,00092,712,960stderr
6Aug 2, 2026 15:412,77735,044,30616,472,0008,805,00092,688,384stderr
7Aug 2, 2026 15:412,78335,108,02216,449,0008,884,00092,692,480stderr
8Aug 2, 2026 15:412,78435,164,55316,534,0008,801,00092,729,344stderr
9Aug 2, 2026 15:412,79035,212,61916,611,0008,785,00092,696,576stderr