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 listAug 14, 2026 18:41marko1597marko1597Score: 5,338Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 14, 2026 18:475,31559,037,38235,685,00012,683,00092,717,056stderr
2Aug 14, 2026 18:475,32059,222,14735,704,00012,713,00092,798,976stderr
3Aug 14, 2026 18:475,32258,963,03535,827,00012,604,00092,766,208stderr
4Aug 14, 2026 18:475,32460,338,62435,714,00012,736,00092,762,112stderr
5Aug 14, 2026 18:475,33858,585,86135,802,00012,780,00092,737,536stderr
6Aug 14, 2026 18:475,35558,645,56235,903,00012,832,00092,725,248stderr
7Aug 14, 2026 18:475,37159,616,72535,930,00012,953,00092,737,536stderr
8Aug 14, 2026 18:475,37858,998,81635,988,00012,960,00092,758,016stderr
9Aug 14, 2026 18:475,43068,863,67936,616,00012,799,00092,704,768stderr