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 listMay 3, 2026 18:41TudyMTudyMScore: 8,354Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 18:468,30391,730,11558,124,00017,438,00094,638,080
2May 3, 2026 18:468,31092,805,31258,078,00017,549,00094,638,080
3May 3, 2026 18:468,32889,172,84258,901,00016,890,00094,593,024
4May 3, 2026 18:468,33694,506,92958,295,00017,566,00094,633,984
5May 3, 2026 18:468,35493,848,43458,569,00017,456,00094,642,176
6May 3, 2026 18:468,35993,131,99158,567,00017,504,00094,638,080
7May 3, 2026 18:468,37992,308,49858,830,00017,426,00094,633,984
8May 3, 2026 18:468,39192,638,07659,678,00016,682,00094,654,464
9May 3, 2026 18:468,39995,224,05659,452,00016,984,00094,629,888