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 17, 2026 09:41Dominique GarmierDominique GarmierError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 11, 2026 01:22Andrew Epstein26.26CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 11, 2026 01:240282,816,614249,609,00022,815,000127,946,752diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 11, 2026 01:240282,487,918249,874,00022,379,000127,946,752diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 11, 2026 01:240283,132,336250,174,00022,631,000127,946,752diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Mar 17, 2026 09:417,772101,582,88150,801,00019,922,00094,797,824
5Mar 17, 2026 09:417,77699,388,77651,825,00018,936,00094,711,808
6Mar 17, 2026 09:417,78298,325,02053,858,00016,955,00094,543,872
7Mar 17, 2026 09:417,78592,156,06750,885,00019,955,00094,564,352
8Mar 17, 2026 09:417,79899,265,30452,975,00017,991,00094,564,352
9Mar 17, 2026 09:417,79897,494,72950,975,00019,990,00094,564,352
10Mar 17, 2026 09:417,79996,756,87850,980,00019,992,00094,564,352
11Mar 17, 2026 09:417,79993,065,50950,978,00019,991,00094,793,728
12Mar 17, 2026 09:417,81397,202,37452,073,00019,026,00094,564,352
13Mar 17, 2026 09:417,81692,854,70354,094,00017,029,00094,650,368
14Mar 17, 2026 09:417,81693,839,21555,099,00016,029,00094,556,160
15Mar 17, 2026 09:417,81995,722,09752,111,00019,040,00094,564,352
16Mar 17, 2026 09:417,82293,396,60353,135,00018,045,00094,797,824
17Mar 17, 2026 09:417,83399,998,28853,208,00018,070,00094,543,872
18Mar 17, 2026 09:417,848100,655,09957,333,00014,081,00094,568,448
19Mar 17, 2026 09:417,84893,558,09051,301,00020,118,00094,793,728
20Mar 17, 2026 09:417,84997,994,61053,321,00018,109,00094,793,728
21Mar 17, 2026 09:417,85594,702,11152,353,00019,129,00094,564,352