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 listJul 7, 2026 20:10Victor MerckléVictor MerckléScore: 2,794Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 7, 2026 20:162,78135,013,45716,565,0008,746,00092,729,344stderr
2Jul 7, 2026 20:162,78134,931,45916,709,0008,602,00092,700,672stderr
3Jul 7, 2026 20:162,78134,944,99516,636,0008,676,00092,733,440stderr
4Jul 7, 2026 20:162,79335,218,68916,740,0008,685,00092,721,152stderr
5Jul 7, 2026 20:162,79435,045,45316,638,0008,792,00092,778,496stderr
6Jul 7, 2026 20:162,79535,675,37416,705,0008,735,00092,794,880stderr
7Jul 7, 2026 20:162,80335,104,29716,715,0008,798,00092,778,496stderr
8Jul 7, 2026 20:162,80435,600,40516,713,0008,805,00092,729,344stderr
9Jul 7, 2026 20:162,81135,211,71116,760,0008,826,00092,815,360stderr