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:15olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 04:35C#_user10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 04:37011,484,38801,611,0002,117,632diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
2Sep 9, 2026 04:37011,349,74001,628,0002,117,632diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
3Sep 9, 2026 04:37011,203,95401,619,0002,117,632diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
4Apr 16, 2026 02:154,16861,809,75821,960,00015,971,00094,683,136
5Apr 16, 2026 02:154,17560,681,86622,998,00014,998,00094,674,944
6Apr 16, 2026 02:154,18259,524,96422,032,00016,023,00094,683,136
7Apr 16, 2026 02:154,18461,786,59319,035,00019,035,00094,683,136
8Apr 16, 2026 02:154,18661,068,62720,049,00018,044,00094,552,064
9Apr 16, 2026 02:154,19668,429,23120,099,00018,089,00094,552,064
10Apr 16, 2026 02:154,20161,022,31118,109,00020,121,00094,547,968
11Apr 16, 2026 02:154,21169,941,05221,179,00017,145,00094,683,136
12Apr 16, 2026 02:154,22161,937,88020,218,00018,196,00094,679,040