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 16:46Victor MerckléVictor MerckléScore: 2,443Success
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 16:522,42631,009,56613,607,0008,476,00092,803,072stderr
2Aug 19, 2026 16:522,42831,182,61813,577,0008,519,00092,737,536stderr
3Aug 19, 2026 16:522,43631,161,48213,698,0008,478,00092,704,768stderr
4Aug 19, 2026 16:522,43731,343,19313,633,0008,548,00092,741,632stderr
5Aug 19, 2026 16:522,44331,172,23613,700,0008,533,00092,807,168stderr
6Aug 19, 2026 16:522,44531,373,28913,671,0008,586,00092,721,152stderr
7Aug 19, 2026 16:522,45431,343,39313,776,0008,556,00092,729,344stderr
8Aug 19, 2026 16:522,46030,717,25213,775,0008,611,00092,819,456stderr
9Aug 19, 2026 16:522,47031,488,83613,835,0008,649,00092,753,920stderr