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 listMar 3, 2026 23:51olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 00:12Andrew Epstein12.12CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 00:150199,952,702158,471,00030,266,000126,451,712diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 18, 2026 00:150215,690,380159,393,00034,265,000126,431,232diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 18, 2026 00:150199,734,855157,639,00030,376,000126,480,384diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Mar 3, 2026 23:5113,357147,732,704101,626,00019,926,00094,552,064
5Mar 3, 2026 23:5113,379147,230,429103,783,00017,962,00094,547,968
6Mar 3, 2026 23:5113,400150,088,478105,952,00015,992,00094,572,544
7Mar 3, 2026 23:5113,403145,730,889101,970,00019,994,00094,547,968
8Mar 3, 2026 23:5113,404144,761,050101,984,00019,996,00094,543,872
9Mar 3, 2026 23:5113,405147,273,90499,988,00021,997,00094,547,968
10Mar 3, 2026 23:5113,418144,314,838100,085,00022,018,00094,793,728
11Mar 3, 2026 23:5113,452150,081,719105,492,00016,918,00094,564,352
12Mar 3, 2026 23:5113,463144,821,938106,578,00015,937,00094,572,544