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 16, 2026 07:41marko1597marko1597Score: 3,460Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 16, 2026 08:003,44139,809,82923,038,0008,279,00092,782,592stderr
2Aug 16, 2026 08:003,44939,732,44923,103,0008,290,00092,729,344stderr
3Aug 16, 2026 08:003,44939,744,94223,071,0008,321,00092,778,496stderr
4Aug 16, 2026 08:003,45339,930,59123,088,0008,336,00092,741,632stderr
5Aug 16, 2026 08:003,46039,847,45923,194,0008,298,00092,737,536stderr
6Aug 16, 2026 08:003,46139,979,70523,151,0008,345,00092,753,920stderr
7Aug 16, 2026 08:003,46139,849,24723,116,0008,383,00092,708,864stderr
8Aug 16, 2026 08:003,46639,870,25123,136,0008,407,00092,721,152stderr
9Aug 16, 2026 08:003,47139,888,18223,170,0008,420,00092,704,768stderr