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 03:23Andrew EpsteinAndrew EpsteinScore: 2,760Success
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 03:402,74035,755,45916,459,0008,477,00092,766,208
2Nov 3, 2026 03:402,74436,403,91616,486,0008,488,00092,725,248
3Nov 3, 2026 03:402,74437,122,30916,461,0008,514,00092,758,016
4Nov 3, 2026 03:402,75235,917,29016,511,0008,533,00092,741,632
5Nov 3, 2026 03:402,76036,482,52216,569,0008,553,00092,778,496
6Nov 3, 2026 03:402,76236,204,55016,599,0008,543,00092,737,536
7Nov 3, 2026 03:402,76835,955,10916,608,0008,582,00092,782,592
8Nov 3, 2026 03:402,77436,047,89716,618,0008,634,00092,749,824
9Nov 3, 2026 03:402,78636,688,06616,677,0008,678,00092,753,920