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:17Karthik ReddyKarthik ReddyError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 13, 2026 12:14Andrew Epstein23.34CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 12:300318,956,437298,735,00011,350,000137,105,408diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Oct 13, 2026 12:300319,111,646298,692,00011,421,000137,170,944diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Oct 13, 2026 12:300319,189,768298,712,00011,477,000137,515,008diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Oct 9, 2026 09:392,25330,852,66411,886,0008,619,00092,901,376
5Oct 9, 2026 09:392,26129,473,79512,010,0008,571,00092,909,568
6Oct 9, 2026 09:392,26429,586,29312,143,0008,467,00092,872,704
7Oct 9, 2026 09:392,26429,576,62011,993,0008,610,00092,852,224
8Oct 9, 2026 09:392,27029,625,42312,126,0008,535,00092,880,896
9Oct 9, 2026 09:392,28030,256,41212,238,0008,514,00092,844,032
10Oct 9, 2026 09:392,28129,794,47512,135,0008,626,00092,872,704
11Oct 9, 2026 09:392,28229,744,77612,028,0008,745,00092,856,320
12Oct 9, 2026 09:392,29330,499,72812,258,0008,610,00092,946,432