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 17:47Victor 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 11, 2026 17:532,73033,795,31416,101,0008,748,00092,762,112
2Jun 11, 2026 17:532,73333,870,69916,127,0008,747,00092,770,304
3Jun 11, 2026 17:532,73433,880,38716,124,0008,758,00092,774,400
4Jun 11, 2026 17:532,73933,872,72216,140,0008,787,00092,684,288
5Jun 11, 2026 17:532,74034,037,89916,151,0008,792,00092,696,576
6Jun 11, 2026 17:532,74333,980,16216,149,0008,820,00092,712,960
7Jun 11, 2026 17:532,75334,122,72616,186,0008,875,00092,700,672
8Jun 11, 2026 17:532,75934,073,45816,231,0008,879,00092,741,632
9Jun 11, 2026 17:532,76034,141,22716,235,0008,890,00092,811,264