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 listSep 10, 2026 12:50Andrew EpsteinAndrew EpsteinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 10, 2026 13:10Tomislav Tunkovic125.25CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 10, 2026 13:130363,765,460334,838,00017,936,000100,683,776diff: map[string]any{ "age": s"18", - "height": s"190.1", + "height": s"190.09999999999999999999999999", "id": s"899576", "married": bool(false), }
2Sep 10, 2026 13:130366,930,975337,830,00018,162,000100,683,776diff: map[string]any{ - "height": s"174.5", + "height": s"0.00000000001745e13", "id": s"239645", "married": bool(false), "phones": []any{map[string]any{"code": string("+2"), "number": s"1232790458"}, map[string]any{"code": string("...
3Sep 10, 2026 13:130362,602,246333,798,00017,834,000100,683,776diff: map[string]any{ "age": s"61", - "height": s"161.5", + "height": s"0.000001615e8", "id": s"832787", "married": bool(true), "phones": []any{map[string]any{"code": string("+0"), "number": s"1525969810"}}, }
4Sep 10, 2026 12:587,43978,032,31850,521,00017,178,00094,392,320
5Sep 10, 2026 12:587,44877,928,40951,823,00015,957,00094,392,320
6Sep 10, 2026 12:587,45578,143,60451,768,00016,077,00094,392,320
7Sep 10, 2026 12:587,50678,603,82251,452,00016,858,00094,392,320
8Sep 10, 2026 12:587,54478,935,03852,646,00016,008,00094,392,320
9Sep 10, 2026 12:587,56279,002,41952,484,00016,332,00094,392,320
10Sep 10, 2026 12:587,62680,389,46252,369,00017,028,00094,392,320
11Sep 10, 2026 12:587,70281,053,49653,312,00016,780,00094,392,320
12Sep 10, 2026 12:587,75682,263,52953,535,00017,045,00094,392,320