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 10:35Victor MerckléVictor MerckléScore: 2,578Success
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 10:412,56831,823,76614,587,0008,790,00092,774,400stderr
2Aug 19, 2026 10:412,57432,644,39414,649,0008,777,00092,741,632stderr
3Aug 19, 2026 10:412,57632,521,55814,958,0008,485,00092,774,400stderr
4Aug 19, 2026 10:412,57831,807,50714,671,0008,790,00092,782,592stderr
5Aug 19, 2026 10:412,57832,538,28614,677,0008,790,00092,692,480stderr
6Aug 19, 2026 10:412,58431,906,19614,719,0008,801,00092,717,056stderr
7Aug 19, 2026 10:412,60032,725,24915,022,0008,638,00092,766,208stderr
8Aug 19, 2026 10:412,60132,731,04515,039,0008,637,00092,717,056stderr
9Aug 19, 2026 10:412,60232,115,93815,017,0008,663,00092,729,344stderr