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 listMay 4, 2026 19:44Victor MerckléVictor MerckléScore: 3,175Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2026 19:493,16645,798,64120,119,0008,696,00092,995,584
2May 4, 2026 19:493,16942,974,97220,129,0008,717,00093,040,640
3May 4, 2026 19:493,17047,004,80520,138,0008,718,00093,024,256
4May 4, 2026 19:493,17545,484,25720,140,0008,755,00093,052,928
5May 4, 2026 19:493,17547,101,77520,140,0008,760,00093,036,544
6May 4, 2026 19:493,18245,077,09620,155,0008,803,00092,999,680
7May 4, 2026 19:493,18545,831,84020,169,0008,821,00093,016,064
8May 4, 2026 19:493,18845,170,14020,161,0008,852,00092,954,624
9May 4, 2026 19:493,19245,873,67820,248,0008,804,00093,016,064