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 listDec 23, 2025 18:24AnSaAnSaScore: 3,641Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 23, 2025 18:243,61458,883,03718,934,00013,951,00097,148,928
2Dec 23, 2025 18:243,62658,859,24320,000,00013,000,00097,185,792
3Dec 23, 2025 18:243,62762,146,05516,001,00017,001,00097,284,096
4Dec 23, 2025 18:243,63058,383,74918,020,00015,017,00097,247,232
5Dec 23, 2025 18:243,64158,543,45720,083,00013,054,00097,189,888
6Dec 23, 2025 18:243,64959,278,26420,127,00013,082,00097,222,656
7Dec 23, 2025 18:243,66060,409,17119,175,00014,128,00097,218,560
8Dec 23, 2025 18:243,66455,389,81022,228,00011,114,00097,177,600
9Dec 23, 2025 18:243,68958,828,23720,736,00012,836,00097,337,344