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 8, 2026 04:59Karthik ReddyKarthik ReddyError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Oct 13, 2026 12:14Andrew Epstein46.76CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 12:320316,368,629295,855,00011,552,000137,203,712diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Oct 13, 2026 12:320316,554,576296,087,00011,443,000137,220,096diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Oct 13, 2026 12:320316,110,772295,789,00011,403,000136,953,856diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Oct 8, 2026 05:042,28129,681,12712,172,0008,590,00092,913,664
5Oct 8, 2026 05:042,29029,918,34912,138,0008,704,00092,864,512
6Oct 8, 2026 05:042,29329,772,88212,301,0008,572,00092,852,224
7Oct 8, 2026 05:042,29729,874,32112,279,0008,629,00092,860,416
8Oct 8, 2026 05:042,29729,913,88812,276,0008,627,00092,897,280
9Oct 8, 2026 05:042,30029,993,34212,352,0008,582,00092,880,896
10Oct 8, 2026 05:042,30829,991,83112,421,0008,585,00092,860,416
11Oct 8, 2026 05:042,31029,989,59412,327,0008,700,00092,880,896
12Oct 8, 2026 05:042,31130,055,47312,401,0008,635,00092,946,432