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 listNov 3, 2026 01:30Andrew EpsteinAndrew EpsteinScore: 3,472Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 01:473,45442,966,40322,860,0008,580,00092,688,384
2Nov 3, 2026 01:473,45942,312,82923,034,0008,444,00092,778,496
3Nov 3, 2026 01:473,46342,438,49423,078,0008,439,00092,766,208
4Nov 3, 2026 01:473,46942,449,38123,088,0008,484,00092,733,440
5Nov 3, 2026 01:473,47242,464,22723,092,0008,509,00092,717,056
6Nov 3, 2026 01:473,47642,497,16923,081,0008,551,00092,803,072
7Nov 3, 2026 01:473,47642,981,16323,098,0008,539,00092,729,344
8Nov 3, 2026 01:473,47944,600,66723,135,0008,525,00092,712,960
9Nov 3, 2026 01:473,48543,109,49723,233,0008,484,00092,782,592