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 8, 2026 04:42Victor 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 8, 2026 04:492,72533,884,67616,082,0008,721,00092,721,152
2Jun 8, 2026 04:492,73333,992,68416,126,0008,752,00092,762,112
3Jun 8, 2026 04:492,73533,987,76516,144,0008,745,00092,749,824
4Jun 8, 2026 04:492,73733,931,68816,134,0008,778,00092,745,728
5Jun 8, 2026 04:492,74034,026,57416,086,0008,857,00092,737,536
6Jun 8, 2026 04:492,74034,010,90616,192,0008,744,00092,749,824
7Jun 8, 2026 04:492,74534,073,29616,177,0008,807,00092,741,632
8Jun 8, 2026 04:492,75234,134,12016,170,0008,877,00092,733,440
9Jun 8, 2026 04:492,76234,219,77216,251,0008,889,00092,745,728