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 14, 2026 01:49Andrew EpsteinAndrew EpsteinScore: 4,983Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 02:004,96255,452,92635,882,0009,279,00092,778,496stderr
2Sep 14, 2026 02:004,97156,781,63935,894,0009,346,00092,712,960stderr
3Sep 14, 2026 02:004,97656,281,26535,951,0009,333,00092,737,536stderr
4Sep 14, 2026 02:004,97955,580,28635,928,0009,383,00092,700,672stderr
5Sep 14, 2026 02:004,98355,582,48735,940,0009,406,00092,733,440stderr
6Sep 14, 2026 02:004,98855,707,14435,956,0009,440,00092,745,728stderr
7Sep 14, 2026 02:004,98955,682,66735,988,0009,415,00092,753,920stderr
8Sep 14, 2026 02:005,00356,534,34636,044,0009,492,00092,749,824stderr
9Sep 14, 2026 02:005,00756,554,46036,007,0009,559,00092,762,112stderr