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 4, 2026 04:40olliecrowolliecrowScore: 8,296Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 4, 2026 04:198,24499,660,81159,013,00016,003,00094,547,968
2Mar 4, 2026 04:198,252103,845,60859,073,00016,019,00094,564,352
3Mar 4, 2026 04:198,253101,366,73558,080,00017,023,00094,572,544
4Mar 4, 2026 04:198,25899,761,51657,116,00018,036,00094,560,256
5Mar 4, 2026 04:408,263106,731,01260,155,00015,038,00094,568,448
6Mar 4, 2026 04:408,267101,648,77459,393,00015,838,00094,556,160
7Mar 4, 2026 04:408,280100,788,96660,476,00014,871,00094,552,064
8Mar 4, 2026 04:198,290102,966,52559,555,00015,881,00094,572,544
9Mar 4, 2026 04:198,292104,312,56858,576,00016,877,00094,547,968
10Mar 4, 2026 04:198,296100,413,30758,605,00016,886,00094,543,872
11Mar 4, 2026 04:198,300108,064,59759,631,00015,901,00094,552,064
12Mar 4, 2026 04:408,302105,792,90358,427,00017,125,00094,552,064
13Mar 4, 2026 04:198,305101,700,98257,675,00017,899,00094,572,544
14Mar 4, 2026 04:408,311109,686,93158,711,00016,916,00094,556,160
15Mar 4, 2026 04:408,316102,215,19959,743,00015,931,00094,556,160
16Mar 4, 2026 04:408,323102,316,05458,801,00016,942,00094,543,872
17Mar 4, 2026 04:408,32797,094,99358,823,00016,949,00094,552,064
18Mar 4, 2026 04:408,392103,803,47260,292,00016,077,00094,556,160