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 10:19Victor MerckléVictor MerckléScore: 2,598Success
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 10:252,57332,089,42414,843,0008,574,00092,762,112stderr
2Aug 19, 2026 10:252,58532,322,98314,931,0008,594,00092,721,152stderr
3Aug 19, 2026 10:252,58632,620,96914,989,0008,545,00092,737,536stderr
4Aug 19, 2026 10:252,59831,935,55714,886,0008,757,00092,733,440stderr
5Aug 19, 2026 10:252,59832,606,83214,972,0008,676,00092,729,344stderr
6Aug 19, 2026 10:252,59832,747,37714,845,0008,802,00092,688,384stderr
7Aug 19, 2026 10:252,62132,216,25914,968,0008,886,00092,721,152stderr
8Aug 19, 2026 10:252,62232,719,89015,097,0008,767,00092,753,920stderr
9Aug 19, 2026 10:252,62332,912,23114,977,0008,900,00092,733,440stderr