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:15olliecrowolliecrowScore: 4,186Success
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:154,16861,809,75821,960,00015,971,00094,683,136
2Apr 16, 2026 02:154,17560,681,86622,998,00014,998,00094,674,944
3Apr 16, 2026 02:154,18259,524,96422,032,00016,023,00094,683,136
4Apr 16, 2026 02:154,18461,786,59319,035,00019,035,00094,683,136
5Apr 16, 2026 02:154,18661,068,62720,049,00018,044,00094,552,064
6Apr 16, 2026 02:154,19668,429,23120,099,00018,089,00094,552,064
7Apr 16, 2026 02:154,20161,022,31118,109,00020,121,00094,547,968
8Apr 16, 2026 02:154,21169,941,05221,179,00017,145,00094,683,136
9Apr 16, 2026 02:154,22161,937,88020,218,00018,196,00094,679,040