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 listSep 4, 2026 23:16Victor MerckléVictor MerckléScore: 2,365Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 23:292,34229,670,59012,832,0008,489,00092,741,632stderr
2Sep 4, 2026 23:292,35829,809,18612,988,0008,473,00092,770,304stderr
3Sep 4, 2026 23:292,36029,672,00712,829,0008,655,00092,762,112stderr
4Sep 4, 2026 23:292,36330,505,54312,991,0008,515,00092,774,400stderr
5Sep 4, 2026 23:292,36529,950,15613,001,0008,523,00092,737,536stderr
6Sep 4, 2026 23:292,36929,928,19313,052,0008,506,00092,749,824stderr
7Sep 4, 2026 23:292,37630,184,60413,011,0008,613,00092,729,344stderr
8Sep 4, 2026 23:292,37830,059,83413,035,0008,607,00092,741,632stderr
9Sep 4, 2026 23:292,38330,065,55813,092,0008,599,00092,803,072stderr