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 19:35marko1597marko1597Score: 4,169Success
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 19:554,14046,875,76025,458,00012,223,00092,766,208stderr
2Aug 14, 2026 19:554,15246,199,47925,487,00012,303,00092,729,344stderr
3Aug 14, 2026 19:554,15746,200,82225,489,00012,342,00092,778,496stderr
4Aug 14, 2026 19:554,16546,213,32225,573,00012,332,00092,774,400stderr
5Aug 14, 2026 19:554,16946,313,67325,481,00012,463,00092,753,920stderr
6Aug 14, 2026 19:554,17246,957,24425,570,00012,398,00092,717,056stderr
7Aug 14, 2026 19:554,17346,362,61625,552,00012,424,00092,717,056stderr
8Aug 14, 2026 19:554,19446,639,68825,697,00012,474,00092,774,400stderr
9Aug 14, 2026 19:554,20346,575,97625,713,00012,538,00092,692,480stderr