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 listJan 11, 2025 10:31Mikhail ShirokovMikhail ShirokovError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 17, 2026 22:59Andrew Epstein37.53CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 23:000272,050,979227,539,00035,794,000111,841,280diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 17, 2026 23:000272,147,978227,732,00035,606,000112,103,424diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 17, 2026 23:000271,944,568227,663,00035,484,000112,009,216diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Jan 11, 2025 10:3110,735123,835,94087,722,0009,968,000103,178,240
5Jan 11, 2025 10:3110,737121,432,83088,731,0008,972,000103,178,240
6Jan 11, 2025 10:3110,753122,513,72989,861,0007,987,000103,174,144
7Jan 11, 2025 10:3110,753124,057,83288,865,0008,986,000103,141,376
8Jan 11, 2025 10:3110,753128,782,89488,865,0008,986,000103,317,504
9Jan 11, 2025 10:3110,762122,461,21788,938,0008,993,000103,211,008
10Jan 11, 2025 10:3110,762121,179,89488,938,0008,993,000103,268,352
11Jan 11, 2025 10:3110,764123,427,73587,960,0009,995,000103,215,104
12Jan 11, 2025 10:3110,779123,195,02489,083,0009,008,000103,243,776