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 listSep 19, 2026 13:28Andrew EpsteinAndrew EpsteinScore: 3,233Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 19, 2026 13:513,21940,421,60220,630,0008,669,00092,770,304stderr
2Sep 19, 2026 13:513,22540,471,57520,813,0008,543,00092,721,152stderr
3Sep 19, 2026 13:513,22640,486,94620,826,0008,534,00092,782,592stderr
4Sep 19, 2026 13:513,22940,478,47320,814,0008,570,00092,778,496stderr
5Sep 19, 2026 13:513,23340,553,51020,675,0008,746,00092,774,400stderr
6Sep 19, 2026 13:513,23740,597,74520,877,0008,585,00092,712,960stderr
7Sep 19, 2026 13:513,24240,587,33920,708,0008,802,00092,766,208stderr
8Sep 19, 2026 13:513,24639,888,93920,896,0008,651,00092,778,496stderr
9Sep 19, 2026 13:513,25240,806,56820,910,0008,688,00092,774,400stderr