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 01:05olliecrowolliecrowScore: 11,790Success
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 00:3011,737132,030,31189,836,00016,969,00094,572,544
2Mar 4, 2026 00:3011,749129,911,17590,927,00015,987,00094,552,064
3Mar 4, 2026 00:0411,752132,205,46389,956,00016,991,00094,552,064
4Mar 4, 2026 00:3011,756129,908,90790,984,00015,997,00094,789,632
5Mar 4, 2026 00:3011,757128,811,42990,993,00015,998,00094,552,064
6Mar 4, 2026 00:3011,757135,556,72788,993,00017,998,00094,547,968
7Mar 4, 2026 00:3011,763134,234,25190,193,00016,849,00094,547,968
8Mar 4, 2026 00:3011,766127,801,80091,061,00016,010,00094,646,272
9Mar 4, 2026 00:0411,767133,879,97588,065,00019,014,00094,801,920
10Mar 4, 2026 00:4311,770128,548,05890,089,00017,016,00094,572,544
11Mar 4, 2026 00:4311,779130,342,45291,163,00016,028,00094,547,968
12Mar 4, 2026 01:3711,780128,062,53189,168,00018,034,00094,547,968
13Mar 4, 2026 01:0511,780135,987,06390,169,00017,032,00094,572,544
14Mar 4, 2026 01:3711,784144,124,77791,199,00016,035,00094,572,544
15Mar 4, 2026 00:5911,788134,834,48490,229,00017,043,00094,543,872
16Mar 4, 2026 00:0411,790140,066,50990,247,00017,046,00094,572,544
17Mar 4, 2026 00:0411,790134,010,12490,245,00017,046,00094,773,248
18Mar 4, 2026 00:0411,790127,353,02092,245,00015,040,00094,552,064
19Mar 4, 2026 00:0411,799138,010,15690,473,00016,901,00094,547,968
20Mar 4, 2026 01:3711,803137,592,38692,348,00015,056,00094,801,920
21Mar 4, 2026 00:5911,805134,827,59792,366,00015,059,00094,564,352
22Mar 4, 2026 00:0411,806135,543,25590,367,00017,069,00094,568,448
23Mar 4, 2026 00:3011,813134,877,89787,590,00019,906,00094,547,968
24Mar 4, 2026 01:0511,813136,922,56792,425,00015,069,00094,572,544
25Mar 4, 2026 00:0411,815133,650,23288,604,00018,915,00094,547,968
26Mar 4, 2026 01:0511,825134,659,73090,673,00016,939,00094,552,064
27Mar 4, 2026 00:4311,830132,532,78689,714,00017,942,00094,572,544
28Mar 4, 2026 00:3011,840131,358,54891,780,00015,961,00094,560,256
29Mar 4, 2026 00:5911,843132,988,60691,806,00015,966,00094,568,448
30Mar 4, 2026 00:0411,874131,832,71190,213,00017,844,00094,543,872