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 listOct 9, 2026 08:13Karthik ReddyKarthik ReddyError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 13, 2026 12:02Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 12:060332,393,999311,935,00011,707,000137,400,320diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Oct 13, 2026 12:060332,199,142312,132,00011,523,000137,457,664diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Oct 13, 2026 12:060331,521,736311,273,00011,509,000137,015,296diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Oct 9, 2026 08:422,28329,538,83012,154,0008,624,00092,930,048
5Oct 9, 2026 08:422,29029,716,74012,385,0008,460,00092,921,856
6Oct 9, 2026 08:422,29529,498,51312,269,0008,624,00092,868,608
7Oct 9, 2026 08:422,30229,741,72912,466,0008,484,00092,856,320
8Oct 9, 2026 08:422,30929,765,14012,513,0008,501,00092,848,128
9Oct 9, 2026 08:422,30929,888,36712,422,0008,592,00092,864,512
10Oct 9, 2026 08:422,32029,865,69912,498,0008,617,00092,905,472
11Oct 9, 2026 08:422,32629,905,58012,571,0008,604,00092,884,992
12Oct 9, 2026 08:422,34937,389,06812,905,0008,476,00092,839,936