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 6, 2026 06:28olliecrowolliecrowScore: 4,222Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 6, 2026 06:344,20454,554,20021,596,00016,663,00094,658,560
2May 6, 2026 06:344,21455,184,87321,556,00016,797,00094,654,464
3May 6, 2026 06:344,21753,454,84021,626,00016,750,00094,662,656
4May 6, 2026 06:344,21754,677,72221,643,00016,736,00094,670,848
5May 6, 2026 06:344,22254,549,91421,603,00016,824,00094,674,944
6May 6, 2026 06:344,23256,798,57821,592,00016,924,00094,662,656
7May 6, 2026 06:344,24355,943,18221,196,00017,421,00094,654,464
8May 6, 2026 06:344,24854,515,30221,632,00017,031,00094,670,848
9May 6, 2026 06:344,26856,449,94021,158,00017,687,00094,650,368