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 18, 2026 06:11Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 11:33Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 11:35010,868,78401,395,0002,117,632diff:   map[string]any{ -  "age": s"51", -  "height": s"164.3", +  "height": s"51",    "id": s"517196", -  "married": bool(false), +  "married": s"64.3", -  "phones": []any{ -  map[string]any{"code": string("+8"), "number": s"171...
2Jul 6, 2026 11:35010,503,15301,415,0002,117,632diff:   map[string]any{ -  "age": s"51", -  "height": s"164.3", +  "height": s"51",    "id": s"517196", -  "married": bool(false), +  "married": s"64.3", -  "phones": []any{ -  map[string]any{"code": string("+8"), "number": s"171...
3Jul 6, 2026 11:35010,606,86901,387,0002,117,632diff:   map[string]any{ -  "age": s"51", -  "height": s"164.3", +  "height": s"51",    "id": s"517196", -  "married": bool(false), +  "married": s"64.3", -  "phones": []any{ -  map[string]any{"code": string("+8"), "number": s"171...
4Jan 18, 2026 06:185,71975,188,47831,024,00021,016,00094,670,848
5Jan 18, 2026 06:115,72478,521,24429,050,00023,040,00094,552,064
6Jan 18, 2026 06:135,72577,818,39732,061,00020,038,00094,670,848
7Jan 18, 2026 06:185,73376,115,79331,102,00021,069,00094,666,752
8Jan 18, 2026 06:135,74077,756,86631,139,00021,094,00094,662,656
9Jan 18, 2026 06:185,74475,326,40032,165,00020,103,00094,552,064
10Jan 18, 2026 06:185,74574,986,53232,172,00020,107,00094,560,256
11Jan 18, 2026 06:115,74979,698,49531,186,00021,126,00094,666,752
12Jan 18, 2026 06:135,75278,616,20933,218,00019,126,00094,662,656
13Jan 18, 2026 06:115,75284,693,26530,197,00022,144,00094,744,576
14Jan 18, 2026 06:135,75483,092,37129,200,00023,158,00094,674,944
15Jan 18, 2026 06:185,75576,871,70533,232,00019,134,00094,662,656
16Jan 18, 2026 06:115,75577,778,60629,206,00023,163,00094,679,040
17Jan 18, 2026 06:135,75782,576,91630,222,00022,163,00094,666,752
18Jan 18, 2026 06:185,75874,945,45531,238,00021,161,00094,552,064
19Jan 18, 2026 06:135,76184,786,81129,676,00022,752,00094,666,752
20Jan 18, 2026 06:115,76378,119,08630,256,00022,187,00094,552,064
21Jan 18, 2026 06:115,76585,246,47034,301,00018,159,00094,552,064
22Jan 18, 2026 06:185,76785,538,12528,259,00024,222,00094,674,944
23Jan 18, 2026 06:115,76984,441,54829,279,00023,221,00094,662,656
24Jan 18, 2026 06:115,77783,130,09229,317,00023,251,00094,662,656
25Jan 18, 2026 06:135,79283,035,34630,827,00021,877,00094,552,064
26Jan 18, 2026 06:185,79579,843,00630,424,00022,311,00094,670,848
27Jan 18, 2026 06:135,86781,811,76632,233,00021,153,00094,662,656
28Jan 18, 2026 06:135,90179,122,64630,826,00022,871,00094,670,848
29Jan 18, 2026 06:185,93476,785,22429,000,00025,000,00094,670,848
30Jan 18, 2026 06:115,95680,736,13929,106,00025,091,00094,670,848