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 5, 2026 03:03olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 04:14C#_user10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 04:16011,070,46201,313,00024,576diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
2Sep 9, 2026 04:16010,996,74901,314,00024,576diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
3Sep 9, 2026 04:16011,073,11501,374,00024,576diff: map[string]any{ - "age": s"123", + "age": s"12", "height": s"456.7", "id": s"1", "married": bool(false), }
4May 5, 2026 03:094,15954,617,54921,175,00016,672,00094,666,752
5May 5, 2026 03:094,16454,037,10121,147,00016,751,00094,666,752
6May 5, 2026 03:094,16454,826,81221,232,00016,665,00094,670,848
7May 5, 2026 03:094,17354,756,92521,291,00016,691,00094,666,752
8May 5, 2026 03:094,17955,971,27421,194,00016,835,00094,658,560
9May 5, 2026 03:094,19058,173,29221,245,00016,887,00094,662,656
10May 5, 2026 03:094,19957,677,64321,319,00016,896,00094,658,560
11May 5, 2026 03:094,20355,305,89521,216,00017,036,00094,666,752
12May 5, 2026 03:094,20854,683,01621,209,00017,087,00094,662,656