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 17:02Victor MerckléVictor MerckléScore: 2,740Success
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 17:072,72233,718,03015,913,0008,864,00092,704,768
2Jun 11, 2026 17:072,72233,898,96216,090,0008,686,00092,737,536
3Jun 11, 2026 17:072,73734,010,19616,147,0008,763,00092,737,536
4Jun 11, 2026 17:072,73833,901,36816,122,0008,800,00092,766,208
5Jun 11, 2026 17:072,74034,362,10016,162,0008,774,00092,733,440
6Jun 11, 2026 17:072,74034,348,99816,161,0008,779,00092,741,632
7Jun 11, 2026 17:072,74834,462,40816,229,0008,784,00092,766,208
8Jun 11, 2026 17:072,75734,201,36516,212,0008,884,00092,762,112
9Jun 11, 2026 17:072,76534,642,55316,268,0008,899,00092,733,440