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 03:39olliecrowolliecrowScore: 9,803Success
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 03:399,763112,830,52875,866,00012,977,00094,543,872
2Mar 4, 2026 03:399,775118,034,50569,961,00018,989,00094,605,312
3Mar 4, 2026 03:329,783110,479,37569,023,00020,006,00094,556,160
4Mar 4, 2026 03:329,786115,905,52667,043,00022,014,00094,552,064
5Mar 4, 2026 03:329,792111,562,65066,080,00023,028,00094,568,448
6Mar 4, 2026 03:329,793112,789,22168,092,00021,028,00094,568,448
7Mar 4, 2026 03:329,796113,499,73273,122,00016,026,00094,556,160
8Mar 4, 2026 03:399,799113,513,77573,143,00016,031,00094,552,064
9Mar 4, 2026 03:329,800119,410,58767,133,00022,043,00094,552,064
10Mar 4, 2026 03:329,803112,357,02966,151,00023,052,00094,547,968
11Mar 4, 2026 03:399,806112,924,54772,193,00017,045,00094,556,160
12Mar 4, 2026 03:329,808119,587,85365,188,00024,069,00094,556,160
13Mar 4, 2026 03:399,809114,245,47069,205,00020,059,00094,552,064
14Mar 4, 2026 03:399,813120,080,50968,230,00021,071,00094,552,064
15Mar 4, 2026 03:399,817111,801,96769,262,00020,075,00094,650,368
16Mar 4, 2026 03:399,836118,488,31276,582,00012,929,00094,560,256
17Mar 4, 2026 03:329,853113,364,19973,722,00015,940,00094,547,968
18Mar 4, 2026 03:399,880113,334,79079,917,0009,989,00094,543,872