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 listAug 14, 2026 14:32marko1597marko1597Error
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 18:34Tomislav Tunkovic30.57CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 18:50012,660,1441,077,00002,121,728EOFstderr
2Sep 4, 2026 18:50010,675,6891,060,00002,121,728EOFstderr
3Sep 4, 2026 18:50010,858,4631,059,00002,121,728diff: map[string]any{ "height": s"190.8", "id": s"781394", "married": bool(false), "phones": []any{ map[string]any{"code": string("+1"), "number": s"1229972313"}, - map[string]any{"code": string("+0"), "number": s"1508713283"}...stderr
4Aug 14, 2026 14:465,75662,207,27231,629,00020,753,00094,396,416stderr
5Aug 14, 2026 14:465,76762,313,90931,580,00020,903,00094,396,416stderr
6Aug 14, 2026 14:465,77262,258,27831,786,00020,744,00094,396,416stderr
7Aug 14, 2026 14:465,78062,374,95531,774,00020,825,00094,396,416stderr
8Aug 14, 2026 14:465,78162,376,58531,695,00020,918,00094,396,416stderr
9Aug 14, 2026 14:465,78162,395,93731,697,00020,915,00094,396,416stderr
10Aug 14, 2026 14:465,78562,443,80631,695,00020,956,00094,396,416stderr
11Aug 14, 2026 14:465,82062,684,39831,837,00021,125,00094,396,416stderr
12Aug 14, 2026 14:465,82062,805,66531,811,00021,157,00094,396,416stderr