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 listApr 22, 2025 18:05Aniruddha DebAniruddha DebError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 00:39Andrew Epstein10.02CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 00:4309,858,2401,330,000077,824diff: map[string]any{ + "age": s"0", "height": s"169.1", - "id": s"4294967295", + "id": s"-1", "married": bool(true), }
2Sep 18, 2026 00:4309,884,1281,464,000077,824diff: map[string]any{ + "age": s"0", "height": s"169.1", - "id": s"4294967295", + "id": s"-1", "married": bool(true), }
3Sep 18, 2026 00:4309,867,8671,446,000077,824diff: map[string]any{ + "age": s"0", "height": s"169.1", - "id": s"4294967295", + "id": s"-1", "married": bool(true), }
4Apr 22, 2025 18:0599,187928,214,574876,614,00025,988,000121,958,400
5Apr 22, 2025 18:0599,626931,079,246884,608,00021,990,000121,966,592
6Apr 22, 2025 18:0599,646931,440,018887,781,00018,995,000124,170,240
7Apr 22, 2025 18:0599,681931,608,883879,129,00027,972,000122,073,088
8Apr 22, 2025 18:0599,785932,863,328880,076,00027,970,000124,170,240
9Apr 22, 2025 18:0599,812934,560,128877,315,00030,975,000124,170,240
10Apr 22, 2025 18:05100,128930,586,398883,187,00027,974,000124,059,648
11Apr 22, 2025 18:05100,278932,843,876897,540,00014,992,000121,810,944
12Apr 22, 2025 18:05100,639941,328,537894,841,00020,972,000122,073,088