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 21, 2026 00:48Victor MerckléVictor MerckléScore: 2,672Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 21, 2026 00:532,66331,679,28115,552,0008,689,00092,712,960
2Jun 21, 2026 00:532,66431,604,93115,574,0008,673,00092,725,248
3Jun 21, 2026 00:532,66631,809,62715,606,0008,662,00092,782,592
4Jun 21, 2026 00:532,67231,739,35515,593,0008,728,00092,721,152
5Jun 21, 2026 00:532,67231,747,59915,608,0008,711,00092,676,096
6Jun 21, 2026 00:532,67632,036,41515,629,0008,726,00092,762,112
7Jun 21, 2026 00:532,67831,880,91115,588,0008,789,00092,725,248
8Jun 21, 2026 00:532,68731,942,86915,657,0008,798,00092,712,960
9Jun 21, 2026 00:532,69231,951,39215,676,0008,825,00092,766,208