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 listMar 3, 2026 22:27olliecrowolliecrowScore: 16,098Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 3, 2026 22:2716,031171,387,217124,899,00020,983,00094,801,920
2Mar 3, 2026 22:2716,031168,984,436125,902,00019,984,00094,543,872
3Mar 3, 2026 22:2716,052175,988,297125,066,00021,011,00094,572,544
4Mar 3, 2026 22:2716,062173,104,172130,150,00016,018,00094,552,064
5Mar 3, 2026 22:2716,098172,633,678128,551,00017,937,00094,543,872
6Mar 3, 2026 22:2716,100171,252,135128,571,00017,940,00094,793,728
7Mar 3, 2026 22:2716,104171,585,192127,602,00018,940,00094,572,544
8Mar 3, 2026 22:2716,826177,850,567133,104,00020,015,00094,801,920
9Mar 3, 2026 22:2717,354180,557,491136,934,00020,989,00094,572,544