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 listApr 21, 2026 00:29Taylor DettlingTaylor DettlingScore: 18,564Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 00:3318,439189,657,79771,913,00095,884,00094,752,768
2Apr 21, 2026 00:3318,450189,596,08771,956,00095,941,00094,744,576
3Apr 21, 2026 00:3318,473193,694,61471,045,00097,062,00094,756,864
4Apr 21, 2026 00:3318,492194,508,29772,122,00096,162,00094,752,768
5Apr 21, 2026 00:3318,564186,626,89471,974,00096,965,00094,773,248
6Apr 21, 2026 00:3318,572190,725,69773,003,00096,005,00094,765,056
7Apr 21, 2026 00:3318,608194,652,14771,140,00098,194,00094,752,768
8Apr 21, 2026 00:3318,666190,676,44970,942,00098,919,00094,752,768
9Apr 21, 2026 00:3318,842195,596,81571,777,00099,690,00094,756,864