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 listJun 21, 2025 21:10Aniruddha DebAniruddha DebError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 00:04Victor Mercklé149.31CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 00:06011,427,65102,084,0002,125,824invalid character 'g' looking for beginning of valuestderr
2Jul 6, 2026 00:06011,965,13202,201,0002,125,824invalid character 'g' looking for beginning of valuestderr
3Jul 6, 2026 00:06011,629,66702,220,0002,125,824invalid character 'g' looking for beginning of valuestderr
4Jun 21, 2025 21:083,14159,063,39618,728,0009,857,00094,658,560
5Jun 21, 2025 20:513,14654,596,50819,744,0008,885,00094,388,224
6Jun 21, 2025 20:513,14851,790,01319,759,0008,891,00094,392,320
7Jun 21, 2025 20:513,15464,470,84518,804,0009,896,00094,375,936
8Jun 21, 2025 21:113,15556,139,39119,800,0008,910,00094,482,432
9Jun 21, 2025 21:083,15655,028,50418,818,0009,904,00094,412,800
10Jun 21, 2025 20:513,15752,262,23420,518,0008,207,00094,384,128
11Jun 21, 2025 21:083,15858,073,64018,826,0009,908,00094,380,032
12Jun 21, 2025 21:083,16055,370,55918,843,0009,917,00094,412,800
13Jun 21, 2025 21:083,16151,007,89218,846,0009,919,00094,330,880
14Jun 21, 2025 21:113,16457,188,40719,856,0008,935,00094,375,936
15Jun 21, 2025 21:083,16552,615,46919,863,0008,938,00094,334,976
16Jun 21, 2025 20:513,16753,683,83218,884,0009,939,00094,412,800
17Jun 21, 2025 21:103,16850,477,17319,563,0009,267,00094,384,128
18Jun 21, 2025 21:083,16956,011,17418,896,0009,945,00094,597,120
19Jun 21, 2025 21:103,17050,503,30817,903,00010,941,00094,429,184
20Jun 21, 2025 20:513,17152,593,73823,703,0005,152,00094,638,080
21Jun 21, 2025 21:083,17552,837,99318,930,0009,963,00094,363,648
22Jun 21, 2025 20:513,17552,020,78318,933,0009,964,00094,400,512
23Jun 21, 2025 21:083,18152,205,14124,951,0003,992,00094,609,408
24Jun 21, 2025 20:513,18453,086,09920,983,0007,993,00094,388,224
25Jun 21, 2025 20:513,18456,957,22422,979,0005,994,00094,580,736
26Jun 21, 2025 21:103,18557,885,54519,989,0008,995,00094,658,560
27Jun 21, 2025 21:113,19758,453,99418,055,00011,034,00094,588,928