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 31, 2026 09:30Dominique GarmierDominique GarmierScore: 5,389Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 30, 2026 18:235,36472,037,44824,904,00023,907,00094,621,696
2Mar 30, 2026 18:235,37173,682,00421,946,00026,934,00094,621,696
3Mar 31, 2026 09:305,37370,525,70425,944,00022,950,00094,617,600
4Mar 30, 2026 18:235,37572,486,16020,961,00027,948,00094,625,792
5Mar 31, 2026 09:305,37772,605,85124,963,00023,965,00094,621,696
6Mar 31, 2026 09:305,38175,272,55226,980,00021,984,00094,560,256
7Mar 30, 2026 18:235,38472,243,68421,433,00027,557,00094,621,696
8Mar 31, 2026 09:305,38470,594,10721,997,00026,997,00094,621,696
9Mar 30, 2026 18:235,38573,403,10625,000,00024,000,00094,629,888
10Mar 30, 2026 18:235,38983,722,04723,021,00026,023,00094,568,448
11Mar 30, 2026 18:235,41373,531,52823,121,00026,137,00094,625,792
12Mar 31, 2026 09:305,41679,400,17923,133,00026,150,00094,621,696
13Mar 31, 2026 09:305,41873,522,14124,148,00025,154,00094,617,600
14Mar 30, 2026 18:235,42776,340,57124,190,00025,198,00094,617,600
15Mar 30, 2026 18:235,43276,453,69424,211,00025,220,00094,617,600
16Mar 31, 2026 09:305,44575,015,65024,777,00024,777,00094,617,600
17Mar 31, 2026 09:305,44676,170,16627,752,00021,805,00094,564,352
18Mar 31, 2026 09:305,45278,775,74627,781,00021,828,00094,625,792