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 27, 2021 13:13Yurkov AlekseyYurkov AlekseyError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:04Tomislav Tunkovic10.00CustomSolution Broken
Sep 9, 2026 02:24Haha Expert10.00CustomSolution Held
Jul 6, 2026 12:56Victor Mercklé10.00CustomSolution Held
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:08011,560,78801,589,0002,121,728diff: map[string]any{ "age": s"42", - "height": s"0", "id": s"642422", "married": bool(true), }
2Sep 9, 2026 11:08011,579,53801,587,0002,121,728diff: map[string]any{ "age": s"33", - "height": s"199.6", + "height": s"199.5999999999999999999999999", "id": s"90973", "married": bool(false), "phones": []any{map[string]any{"code": string("+0"), "number": s"1878919023"}, m...
3Sep 9, 2026 11:08011,685,94301,714,0002,121,728diff: map[string]any{ "age": s"45", - "height": s"157.3", + "height": s"1573000000E-7", "id": s"388580", "married": bool(true), }
4May 27, 2021 13:136,327130,941,19457,576,508092,557,312
5May 27, 2021 13:136,331120,819,08057,609,424092,569,600
6May 27, 2021 13:136,347120,465,03957,760,226092,553,216
7May 27, 2021 13:136,46583,079,13942,881,00015,955,00092,688,384
8May 27, 2021 13:136,47682,822,27740,954,00017,979,00092,471,296
9May 27, 2021 13:136,47883,944,90441,962,00016,984,00092,475,392
10May 27, 2021 13:136,48083,076,12342,976,00015,991,00092,676,096
11May 27, 2021 13:136,48787,461,46441,021,00018,009,00092,700,672
12May 27, 2021 13:136,49983,000,26043,102,00016,037,00091,942,912
13May 27, 2021 13:136,49980,612,65742,099,00017,040,00091,926,528
14May 27, 2021 13:136,50783,875,66744,161,00015,055,00092,463,104
15May 27, 2021 13:136,51486,105,98944,205,00015,070,00092,700,672