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 09:39Victor MerckléVictor MerckléScore: 2,598Success
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 09:452,57732,010,90114,755,0008,696,00092,745,728stderr
2Aug 19, 2026 09:452,58131,892,51114,800,0008,688,00092,729,344stderr
3Aug 19, 2026 09:452,59532,794,03714,823,0008,796,00092,717,056stderr
4Aug 19, 2026 09:452,59532,798,38314,980,0008,640,00092,758,016stderr
5Aug 19, 2026 09:452,59832,628,78414,904,0008,745,00092,708,864stderr
6Aug 19, 2026 09:452,60232,755,36914,906,0008,773,00092,708,864stderr
7Aug 19, 2026 09:452,61032,043,55014,931,0008,824,00092,712,960stderr
8Aug 19, 2026 09:452,62532,888,65814,996,0008,899,00092,721,152stderr
9Aug 19, 2026 09:452,63032,912,76715,051,0008,890,00092,725,248stderr