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 02:03Victor MerckléVictor MerckléScore: 2,863Success
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 02:112,85035,032,21217,030,0008,912,00092,864,512
2Jun 11, 2026 02:112,85334,998,56717,040,0008,926,00092,807,168
3Jun 11, 2026 02:112,85934,878,34917,104,0008,914,00092,766,208
4Jun 11, 2026 02:112,86135,123,57617,105,0008,932,00092,741,632
5Jun 11, 2026 02:112,86335,058,58817,119,0008,941,00092,770,304
6Jun 11, 2026 02:112,86435,167,76417,084,0008,985,00092,708,864
7Jun 11, 2026 02:112,87035,295,71617,097,0009,023,00092,721,152
8Jun 11, 2026 02:112,87435,233,82817,112,0009,049,00092,692,480
9Jun 11, 2026 02:112,87935,188,73117,141,0009,064,00092,745,728