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

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:02Tomislav Tunkovic10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:040174,478,091145,277,00018,190,000100,683,776diff: map[string]any{ - "height": s"0", "id": s"973346", "married": bool(false), "phones": []any{map[string]any{"code": string("+7"), "number": s"1270401327"}, map[string]any{"code": string("+8"), "number": s"1493358924"}}, }
2Sep 9, 2026 11:040173,845,499144,254,00018,624,000100,683,776diff: map[string]any{ "age": s"23", - "height": s"164", + "height": s"164.0", "id": s"73254", "married": bool(false), }
3Sep 9, 2026 11:040174,511,222144,960,00018,601,000100,683,776diff: map[string]any{ "age": s"40", - "height": s"191.4", + "height": s"191.400000000000000000000000001", "id": s"446321", "married": bool(true), "phones": []any{map[string]any{"code": string("+7"), "number": s"1126341770"}}...
4Mar 3, 2026 22:3115,997172,311,878130,514,00015,059,00094,547,968
5Mar 3, 2026 22:3116,005174,687,226127,686,00017,955,00094,543,872
6Mar 3, 2026 22:3116,016169,535,223126,778,00018,966,00094,793,728
7Mar 3, 2026 22:3116,024170,901,574129,839,00015,980,00094,658,560
8Mar 3, 2026 22:3116,036173,470,734130,939,00014,993,00094,801,920
9Mar 3, 2026 22:3116,040169,993,115128,965,00016,995,00094,801,920
10Mar 3, 2026 22:3116,044170,623,517131,001,00015,000,00094,552,064
11Mar 3, 2026 22:3116,047173,653,966127,024,00019,003,00094,547,968
12Mar 3, 2026 22:3116,057171,765,540129,103,00017,013,00094,552,064