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 5, 2026 16:30Victor MerckléVictor MerckléScore: 4,713Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 16:354,68251,695,95120,768,00021,840,00092,745,728
2Jun 5, 2026 16:354,68651,689,36620,763,00021,882,00092,782,592
3Jun 5, 2026 16:354,69551,840,50520,802,00021,926,00092,717,056
4Jun 5, 2026 16:354,70151,873,39720,751,00022,033,00092,745,728
5Jun 5, 2026 16:354,71351,930,17720,763,00022,134,00092,758,016
6Jun 5, 2026 16:354,72852,069,68220,815,00022,213,00092,717,056
7Jun 5, 2026 16:354,72852,068,13820,800,00022,233,00092,803,072
8Jun 5, 2026 16:354,87053,458,89820,116,00024,201,00092,741,632
9Jun 5, 2026 16:354,88753,628,05220,347,00024,133,00092,745,728