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:08olliecrowolliecrowScore: 8,306Success
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:008,273101,412,48458,447,00016,840,00094,547,968
2Mar 4, 2026 04:088,273107,332,63058,220,00017,064,00094,572,544
3Mar 4, 2026 04:008,276102,146,20458,464,00016,845,00094,560,256
4Mar 4, 2026 04:088,285107,121,47259,311,00016,084,00094,547,968
5Mar 4, 2026 04:008,289104,118,04057,568,00017,866,00094,609,408
6Mar 4, 2026 04:088,289102,177,96158,560,00016,873,00094,572,544
7Mar 4, 2026 04:008,291101,954,70957,577,00017,868,00094,556,160
8Mar 4, 2026 04:088,30398,590,25058,656,00016,900,00094,552,064
9Mar 4, 2026 04:008,305101,376,61460,457,00015,114,00094,801,920
10Mar 4, 2026 04:088,306102,998,88359,674,00015,913,00094,560,256
11Mar 4, 2026 04:088,31096,213,25658,709,00016,916,00094,547,968
12Mar 4, 2026 04:008,312100,962,68758,719,00016,919,00094,556,160
13Mar 4, 2026 04:008,315105,208,65958,741,00016,925,00094,560,256
14Mar 4, 2026 04:008,318101,339,07558,765,00016,932,00094,552,064
15Mar 4, 2026 04:088,32198,355,37958,782,00016,937,00094,572,544
16Mar 4, 2026 04:008,327100,828,99958,826,00016,949,00094,572,544
17Mar 4, 2026 04:088,330100,540,19557,848,00017,953,00094,625,792
18Mar 4, 2026 04:088,334102,217,77858,878,00016,964,00094,552,064