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 12, 2026 22:36Victor MerckléVictor MerckléScore: 2,686Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 12, 2026 22:412,66931,799,12915,615,0008,679,00092,762,112
2Jun 12, 2026 22:412,67731,902,53915,624,0008,745,00092,807,168
3Jun 12, 2026 22:412,67931,977,72115,675,0008,708,00092,729,344
4Jun 12, 2026 22:412,68232,128,99715,701,0008,713,00092,762,112
5Jun 12, 2026 22:412,68632,086,88715,652,0008,799,00092,766,208
6Jun 12, 2026 22:412,68832,071,15915,716,0008,752,00092,733,440
7Jun 12, 2026 22:412,69132,095,66615,710,0008,785,00092,762,112
8Jun 12, 2026 22:412,69632,182,66415,707,0008,828,00092,721,152
9Jun 12, 2026 22:412,69932,126,04315,708,0008,854,00092,712,960