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 11, 2026 18:44Victor MerckléVictor MerckléScore: 2,704Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 18:502,68733,473,74015,586,0008,871,00092,766,208
2Jun 11, 2026 18:502,69233,459,68715,760,0008,738,00092,762,112
3Jun 11, 2026 18:502,69333,691,17115,632,0008,883,00092,717,056
4Jun 11, 2026 18:502,69933,618,24115,832,0008,729,00092,737,536
5Jun 11, 2026 18:502,70433,573,08715,853,0008,762,00092,815,360
6Jun 11, 2026 18:502,71134,914,91515,869,0008,805,00092,717,056
7Jun 11, 2026 18:502,71133,770,57215,847,0008,832,00092,708,864
8Jun 11, 2026 18:502,71233,659,48415,877,0008,804,00092,766,208
9Jun 11, 2026 18:502,73641,948,12315,989,0008,917,00092,712,960