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:33Andrew EpsteinAndrew EpsteinScore: 76,677Success
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 14:0476,228704,730,889651,652,00042,025,00092,712,960stderr
2Sep 19, 2026 14:0476,446706,230,273653,531,00042,136,00092,815,360stderr
3Sep 19, 2026 14:0476,576707,344,470654,060,00042,789,00092,717,056stderr
4Sep 19, 2026 14:0476,587708,055,374654,061,00042,885,00092,778,496stderr
5Sep 19, 2026 14:0476,677708,238,315655,680,00042,087,00092,762,112stderr
6Sep 19, 2026 14:0476,727709,470,046655,485,00042,736,00092,790,784stderr
7Sep 19, 2026 14:0476,731709,420,647655,010,00043,243,00092,733,440stderr
8Sep 19, 2026 14:0476,780709,867,524656,102,00042,596,00092,745,728stderr
9Sep 19, 2026 14:0476,930711,215,174657,516,00042,556,00092,753,920stderr