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 02:18olliecrowolliecrowScore: 10,996Success
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 02:1310,932123,142,41781,574,00017,906,00094,552,064
2Mar 4, 2026 02:1310,945125,357,59680,674,00018,923,00094,564,352
3Mar 4, 2026 02:2110,953128,910,42481,735,00017,941,00094,547,968
4Mar 4, 2026 02:2110,959124,159,02481,778,00017,951,00094,564,352
5Mar 4, 2026 02:1310,975126,938,59582,898,00016,979,00094,543,872
6Mar 4, 2026 02:2110,978125,652,50782,915,00016,982,00094,580,736
7Mar 4, 2026 02:2110,982124,889,19482,944,00016,988,00094,552,064
8Mar 4, 2026 02:1310,984127,215,54081,966,00017,992,00094,552,064
9Mar 4, 2026 02:2110,987130,358,16381,983,00017,996,00094,552,064
10Mar 4, 2026 02:1310,989123,073,40782,998,00016,999,00094,568,448
11Mar 4, 2026 02:1810,996121,411,89881,050,00019,011,00094,560,256
12Mar 4, 2026 02:1811,002126,768,31282,096,00018,021,00094,552,064
13Mar 4, 2026 02:1311,003129,029,63783,109,00017,022,00094,564,352
14Mar 4, 2026 02:1311,009126,693,56283,148,00017,030,00094,556,160
15Mar 4, 2026 02:2111,014122,592,11384,191,00016,036,00094,572,544
16Mar 4, 2026 02:2111,021132,847,02381,239,00019,056,00094,801,920
17Mar 4, 2026 02:1811,024123,380,31483,267,00017,054,00094,650,368
18Mar 4, 2026 02:2111,051127,810,91882,463,00018,101,00094,568,448
19Mar 4, 2026 02:1311,072131,880,23189,784,00010,973,00094,547,968
20Mar 4, 2026 02:2111,086122,196,88381,905,00018,978,00094,543,872
21Mar 4, 2026 02:1311,197124,402,23084,909,00016,981,00094,543,872