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:01Victor MerckléVictor MerckléScore: 2,472Success
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:072,45830,754,40613,798,0008,575,00092,749,824stderr
2Aug 19, 2026 16:072,46330,702,87713,891,0008,531,00092,774,400stderr
3Aug 19, 2026 16:072,46530,779,03913,929,0008,503,00092,758,016stderr
4Aug 19, 2026 16:072,46731,456,14413,883,0008,574,00092,770,304stderr
5Aug 19, 2026 16:072,47230,796,80613,942,0008,554,00092,741,632stderr
6Aug 19, 2026 16:072,47531,516,00213,965,0008,564,00092,737,536stderr
7Aug 19, 2026 16:072,47530,995,25813,914,0008,614,00092,770,304stderr
8Aug 19, 2026 16:072,48030,891,25413,912,0008,657,00092,790,784stderr
9Aug 19, 2026 16:072,49431,639,13514,029,0008,667,00092,786,688stderr