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 16:47Victor MerckléVictor MerckléScore: 2,743Success
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 16:522,73133,878,24916,127,0008,730,00092,745,728
2Jun 11, 2026 16:522,73233,895,22216,171,0008,695,00092,700,672
3Jun 11, 2026 16:522,73533,928,55116,173,0008,716,00092,708,864
4Jun 11, 2026 16:522,73634,008,30116,172,0008,727,00092,766,208
5Jun 11, 2026 16:522,74333,980,85616,204,0008,765,00092,676,096
6Jun 11, 2026 16:522,74634,055,24616,204,0008,787,00092,782,592
7Jun 11, 2026 16:522,76534,154,08416,261,0008,907,00092,770,304
8Jun 11, 2026 16:522,76734,182,24616,304,0008,882,00092,766,208
9Jun 11, 2026 16:522,76934,267,92416,315,0008,889,00092,803,072