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 20, 2026 14:38olliecrowolliecrowScore: 8,112Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 14:428,09195,043,81956,712,00016,914,00094,806,016
2Mar 20, 2026 14:448,09496,479,49756,733,00016,920,00094,756,864
3Mar 20, 2026 14:448,09795,044,44755,760,00017,922,00094,760,960
4Mar 20, 2026 14:268,09794,198,55256,759,00016,928,00094,806,016
5Mar 20, 2026 14:438,09996,238,82557,767,00015,935,00094,760,960
6Mar 20, 2026 14:438,10099,177,10457,775,00015,938,00094,765,056
7Mar 20, 2026 14:388,10194,973,53456,782,00016,935,00094,806,016
8Mar 20, 2026 14:428,10294,094,63455,794,00017,934,00094,760,960
9Mar 20, 2026 14:438,10496,632,64758,797,00014,948,00094,765,056
10Mar 20, 2026 14:268,10895,088,19858,828,00014,956,00094,543,872
11Mar 20, 2026 14:408,10893,258,30457,828,00015,952,00094,806,016
12Mar 20, 2026 14:438,10897,268,22356,836,00016,951,00094,806,016
13Mar 20, 2026 14:448,11296,549,98658,857,00014,963,00094,806,016
14Mar 20, 2026 14:408,11295,199,46856,863,00016,959,00094,760,960
15Mar 20, 2026 14:428,11397,510,95556,868,00016,960,00094,756,864
16Mar 20, 2026 14:428,11598,481,60356,880,00016,964,00094,806,016
17Mar 20, 2026 14:428,11697,544,31357,888,00015,969,00094,806,016
18Mar 20, 2026 14:438,11897,161,90557,902,00015,973,00094,806,016
19Mar 20, 2026 14:438,12098,004,69056,920,00016,976,00094,543,872
20Mar 20, 2026 14:448,12394,864,20755,942,00017,981,00094,806,016
21Mar 20, 2026 14:428,12894,137,69058,970,00014,992,00094,543,872
22Mar 20, 2026 14:448,13595,180,17660,026,00014,006,00094,543,872
23Mar 20, 2026 14:448,14992,834,59556,118,00018,038,00094,765,056
24Mar 20, 2026 14:388,158100,831,84857,185,00017,055,00094,756,864
25Mar 20, 2026 14:388,178100,072,07959,336,00015,085,00094,806,016
26Mar 20, 2026 14:408,252111,910,37358,071,00017,020,00094,760,960
27Mar 20, 2026 14:268,286103,234,72057,309,00018,097,00094,756,864