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

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

Challenge History
DateChallengerCostTypeStatus
Oct 13, 2026 12:14Andrew Epstein15.51CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 12:280332,490,033311,914,00011,598,000137,293,824diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Oct 13, 2026 12:280331,743,654311,319,00011,422,000136,994,816diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Oct 13, 2026 12:280332,064,319311,581,00011,504,000137,248,768diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Oct 9, 2026 07:332,26529,731,21912,036,0008,579,00092,893,184
5Oct 9, 2026 07:332,26729,595,24812,094,0008,538,00092,827,648
6Oct 9, 2026 07:332,27329,693,57112,121,0008,572,00092,852,224
7Oct 9, 2026 07:332,28129,712,65712,176,0008,584,00092,893,184
8Oct 9, 2026 07:332,29129,792,65212,193,0008,659,00092,884,992
9Oct 9, 2026 07:332,29429,893,57212,205,0008,673,00092,917,760
10Oct 9, 2026 07:332,29730,333,24612,402,0008,506,00092,893,184
11Oct 9, 2026 07:332,30130,329,18712,486,0008,454,00092,876,800
12Oct 9, 2026 07:332,31730,532,59812,478,0008,608,00092,889,088