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 listJun 7, 2026 05:11Victor MerckléVictor MerckléScore: 2,746Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 7, 2026 05:162,72833,892,91615,959,0008,869,00092,758,016
2Jun 7, 2026 05:162,73033,973,67916,133,0008,715,00092,766,208
3Jun 7, 2026 05:162,73933,992,26116,202,0008,726,00092,745,728
4Jun 7, 2026 05:162,74234,037,39016,183,0008,777,00092,741,632
5Jun 7, 2026 05:162,74634,089,02016,214,0008,780,00092,712,960
6Jun 7, 2026 05:162,74834,033,15916,195,0008,814,00092,753,920
7Jun 7, 2026 05:162,75234,138,87516,073,0008,972,00092,712,960
8Jun 7, 2026 05:162,75834,173,96816,258,0008,848,00092,692,480
9Jun 7, 2026 05:162,77034,256,78116,296,0008,917,00092,762,112