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:22Victor MerckléVictor MerckléScore: 2,750Success
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:272,74034,001,58516,214,0008,726,00092,745,728
2Jun 8, 2026 04:272,74234,076,56016,202,0008,759,00092,762,112
3Jun 8, 2026 04:272,74434,132,20316,189,0008,787,00092,766,208
4Jun 8, 2026 04:272,74734,109,99216,228,0008,778,00092,770,304
5Jun 8, 2026 04:272,75034,177,42816,258,0008,772,00092,725,248
6Jun 8, 2026 04:272,76134,289,80616,313,0008,821,00092,770,304
7Jun 8, 2026 04:272,76634,201,41716,291,0008,887,00092,774,400
8Jun 8, 2026 04:272,77034,273,46316,328,0008,885,00092,753,920
9Jun 8, 2026 04:272,77434,349,58916,344,0008,902,00092,721,152