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 16, 2026 02:12olliecrowolliecrowScore: 4,218Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 16, 2026 02:124,17457,171,47521,991,00015,993,00094,552,064
2Apr 16, 2026 02:124,19763,939,48920,102,00018,092,00094,552,064
3Apr 16, 2026 02:124,21161,245,07029,247,0009,076,00094,679,040
4Apr 16, 2026 02:124,21866,752,17222,221,00016,160,00094,552,064
5Apr 16, 2026 02:124,21862,649,81822,221,00016,161,00094,679,040
6Apr 16, 2026 02:124,22563,806,09119,224,00019,224,00094,666,752
7Apr 16, 2026 02:124,22965,382,24322,698,00015,790,00094,552,064
8Apr 16, 2026 02:124,23069,210,05920,260,00018,234,00094,670,848
9Apr 16, 2026 02:124,25567,785,79524,823,00013,900,00094,670,848