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:28Victor MerckléVictor MerckléScore: 2,797Success
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:342,77534,319,09816,586,0008,675,00092,762,112
2Jun 8, 2026 04:342,78634,447,46016,670,0008,686,00092,741,632
3Jun 8, 2026 04:342,79134,527,76716,830,0008,576,00092,692,480
4Jun 8, 2026 04:342,79234,509,12416,875,0008,534,00092,692,480
5Jun 8, 2026 04:342,79734,514,88016,860,0008,600,00092,770,304
6Jun 8, 2026 04:342,80334,561,93016,862,0008,652,00092,712,960
7Jun 8, 2026 04:342,80334,532,79516,853,0008,662,00092,790,784
8Jun 8, 2026 04:342,80434,616,32316,855,0008,669,00092,725,248
9Jun 8, 2026 04:342,80634,608,36516,892,0008,649,00092,749,824