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:23Victor MerckléVictor MerckléScore: 2,731Success
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:282,72033,831,24916,012,0008,743,00092,704,768
2Jun 11, 2026 17:282,72333,794,39516,056,0008,732,00092,741,632
3Jun 11, 2026 17:282,72533,837,61616,042,0008,758,00092,786,688
4Jun 11, 2026 17:282,72833,896,28116,057,0008,770,00092,790,784
5Jun 11, 2026 17:282,73133,782,88316,086,0008,769,00092,762,112
6Jun 11, 2026 17:282,74233,970,17616,126,0008,835,00092,819,456
7Jun 11, 2026 17:282,75334,143,86216,182,0008,876,00092,766,208
8Jun 11, 2026 17:282,75434,146,61716,154,0008,910,00092,721,152
9Jun 11, 2026 17:282,75534,149,20716,160,0008,911,00092,770,304