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 15, 2026 08:53Tomislav TunkovicTomislav TunkovicScore: 2,808Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 08:592,78933,738,74316,787,0008,601,00092,704,768stderr
2Aug 15, 2026 08:592,80033,668,27316,839,0008,644,00092,745,728stderr
3Aug 15, 2026 08:592,80533,778,67116,878,0008,656,00092,774,400stderr
4Aug 15, 2026 08:592,80734,689,61116,915,0008,629,00092,737,536stderr
5Aug 15, 2026 08:592,80833,892,71116,892,0008,662,00092,778,496stderr
6Aug 15, 2026 08:592,81233,919,83716,931,0008,666,00092,721,152stderr
7Aug 15, 2026 08:592,81834,030,61116,919,0008,731,00092,815,360stderr
8Aug 15, 2026 08:592,82133,938,19816,930,0008,746,00092,778,496stderr
9Aug 15, 2026 08:592,83334,195,24517,034,0008,751,00092,729,344stderr