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 21, 2026 23:41olliecrowolliecrowError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 11:08Tomislav Tunkovic37.38CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 11:1109,422,56001,264,0002,113,536diff: map[string]any{ "age": s"63", - "height": s"164.7", + "height": s"1647e-1", "id": s"626411", "married": bool(false), "phones": []any{map[string]any{"code": string("+8"), "number": s"1296747235"}, map[string]any{"code":...
2Sep 9, 2026 11:1109,363,11701,272,0002,113,536diff: map[string]any{ "age": s"58", - "height": s"174.6", + "height": s"0.01746e+4", "id": s"95209", "married": bool(false), "phones": []any{map[string]any{"code": string("+6"), "number": s"1656904511"}}, }
3Sep 9, 2026 11:1109,412,83401,272,0002,113,536invalid character 'e' looking for beginning of value
4Apr 21, 2026 23:455,68458,665,30733,824,00017,907,00094,814,208
5Apr 21, 2026 23:455,69269,614,84733,869,00017,931,00094,748,672
6Apr 21, 2026 23:455,69458,781,63331,892,00019,932,00094,593,024
7Apr 21, 2026 23:455,69858,788,99434,903,00016,953,00094,605,312
8Apr 21, 2026 23:455,72158,764,87937,048,00015,019,00094,605,312
9Apr 21, 2026 23:455,72258,978,29736,055,00016,024,00094,601,216
10Apr 21, 2026 23:455,73459,077,03735,122,00017,059,00094,605,312
11Apr 21, 2026 23:455,74359,166,50935,182,00017,088,00094,601,216
12Apr 21, 2026 23:455,79558,584,64233,833,00018,907,00094,597,120