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 25, 2026 20:27Dominique GarmierDominique GarmierScore: 17,091Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 25, 2026 18:4816,854174,033,201107,258,00046,111,00094,650,368
2Mar 25, 2026 21:5416,858177,445,547106,285,00047,126,00094,679,040
3Mar 25, 2026 18:4816,903174,465,690107,869,00045,944,00094,580,736
4Mar 25, 2026 18:4816,970183,009,789105,294,00049,137,00094,720,000
5Mar 25, 2026 18:4817,001178,839,392104,805,00049,907,00094,609,408
6Mar 26, 2026 10:3317,025180,067,628102,955,00051,977,00094,666,752
7Mar 25, 2026 18:4817,066177,896,155106,206,00049,095,00094,670,848
8Mar 25, 2026 21:5417,069180,531,644100,214,00055,117,00094,666,752
9Mar 25, 2026 21:0817,072180,325,696109,249,00046,105,00094,642,176
10Mar 25, 2026 21:0817,091179,200,508100,694,00054,833,00094,674,944
11Mar 26, 2026 10:3317,102178,713,051110,735,00044,892,00094,658,560
12Mar 25, 2026 20:2717,105181,066,046104,769,00050,887,00094,633,984
13Mar 26, 2026 10:3317,138184,046,806109,971,00045,987,00094,605,312
14Mar 25, 2026 20:2717,157179,336,761104,089,00052,044,00094,617,600
15Mar 25, 2026 21:5417,157179,444,47298,083,00058,049,00094,789,632
16Mar 25, 2026 21:0817,194178,930,468106,313,00050,148,00094,633,984
17Mar 25, 2026 18:4817,203181,651,182109,685,00046,865,00094,793,728
18Mar 25, 2026 20:2717,325184,834,144108,453,00049,205,00094,601,216