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 listMar 20, 2026 04:11olliecrowolliecrowScore: 4,390Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 04:114,37466,259,66022,887,00016,916,00094,547,968
2Mar 20, 2026 04:114,38161,771,35621,928,00017,941,00094,547,968
3Mar 20, 2026 04:114,38360,711,39222,932,00016,950,00094,670,848
4Mar 20, 2026 04:114,38461,984,28222,941,00016,957,00094,679,040
5Mar 20, 2026 04:114,39066,984,30224,971,00014,982,00094,687,232
6Mar 20, 2026 04:114,39166,029,09323,973,00015,982,00094,679,040
7Mar 20, 2026 04:114,39565,759,27821,997,00017,997,00094,547,968
8Mar 20, 2026 04:114,39864,105,23524,014,00016,009,00094,547,968
9Mar 20, 2026 04:114,42565,370,33722,145,00018,118,00094,683,136