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 listMay 31, 2025 15:33KeefeKeefeError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 02:25C#_user10.08CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 03:120212,610,850169,768,00032,555,000132,141,056diff: map[string]any{ ... // 2 identical entries "id": s"4", "married": bool(true), "phones": []any{ map[string]any{"code": string("+4"), "number": s"1234567890"}, map[string]any{ "code": string("+5"), - "number": s...
2Sep 9, 2026 03:120209,621,608169,894,00029,405,000132,141,056diff: map[string]any{ ... // 2 identical entries "id": s"4", "married": bool(true), "phones": []any{ map[string]any{"code": string("+4"), "number": s"1234567890"}, map[string]any{ "code": string("+5"), - "number": s...
3Sep 9, 2026 03:120211,458,542170,326,00030,933,000131,960,832diff: map[string]any{ ... // 2 identical entries "id": s"4", "married": bool(true), "phones": []any{ map[string]any{"code": string("+4"), "number": s"1234567890"}, map[string]any{ "code": string("+5"), - "number": s...
4May 31, 2025 15:3317,484188,942,658138,091,00021,013,00094,576,640
5May 31, 2025 15:3317,515189,904,908137,330,00022,053,00094,539,776
6May 31, 2025 15:3317,517190,928,015138,354,00021,054,00094,547,968
7May 31, 2025 15:3317,528189,259,216135,583,00023,926,00094,539,776
8May 31, 2025 15:3317,532188,960,136136,606,00022,933,00094,539,776
9May 31, 2025 15:3317,533190,796,322136,615,00022,935,00094,539,776
10May 31, 2025 15:3317,562182,876,030135,846,00023,972,00094,543,872
11May 31, 2025 15:3317,598182,840,217135,121,00025,022,00094,543,872
12May 31, 2025 15:3317,634184,808,994136,551,00023,921,00094,543,872