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 15, 2026 14:14Dominique GarmierDominique GarmierScore: 13,833Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 15, 2026 14:0313,778151,446,431108,331,00017,052,00094,539,776
2Mar 15, 2026 14:1813,791157,820,447106,577,00018,925,00094,642,176
3Mar 15, 2026 14:0313,799150,903,908109,623,00015,945,00094,564,352
4Mar 15, 2026 14:0813,801150,261,618107,650,00017,941,00094,564,352
5Mar 15, 2026 14:1813,803152,561,852106,667,00018,940,00094,547,968
6Mar 15, 2026 14:1813,807152,824,472105,700,00019,943,00094,687,232
7Mar 15, 2026 14:0313,811149,624,677106,732,00018,952,00094,797,824
8Mar 15, 2026 14:2213,816156,561,354107,763,00017,960,00094,564,352
9Mar 15, 2026 14:0813,818153,964,109106,784,00018,961,00094,539,776
10Mar 15, 2026 14:0313,820154,195,997107,795,00017,965,00094,793,728
11Mar 15, 2026 14:2213,820150,419,227108,792,00016,967,00094,564,352
12Mar 15, 2026 14:1813,826150,138,733108,845,00016,975,00094,556,160
13Mar 15, 2026 14:1413,826154,643,277107,843,00017,973,00094,564,352
14Mar 15, 2026 14:2213,828151,829,201109,859,00015,979,00094,650,368
15Mar 15, 2026 14:0313,829152,790,042107,868,00017,978,00094,797,824
16Mar 15, 2026 14:1813,833146,730,084106,902,00018,982,00094,539,776
17Mar 15, 2026 14:0313,841147,497,247106,963,00018,993,00094,793,728
18Mar 15, 2026 14:1813,845150,597,502109,994,00015,999,00094,797,824
19Mar 15, 2026 14:3313,847148,527,506108,010,00018,001,00094,564,352
20Mar 15, 2026 14:0813,850151,753,874110,032,00016,004,00094,650,368
21Mar 15, 2026 14:1813,851151,440,731108,037,00018,006,00094,564,352
22Mar 15, 2026 14:0313,851150,845,157107,034,00019,006,00094,785,536
23Mar 15, 2026 14:3313,851147,529,182110,036,00016,005,00094,638,080
24Mar 15, 2026 14:0313,852148,797,595108,045,00018,007,00094,806,016
25Mar 15, 2026 14:1413,858152,952,039110,097,00016,014,00094,543,872
26Mar 15, 2026 14:3313,865153,100,615109,147,00017,023,00094,564,352
27Mar 15, 2026 14:1413,900153,014,513109,424,00017,066,00094,793,728
28Mar 15, 2026 14:1813,925156,846,071107,764,00018,958,00094,556,160
29Mar 15, 2026 14:1813,977150,985,817109,166,00018,027,00094,564,352
30Mar 15, 2026 14:0313,995151,206,380107,303,00020,056,00094,642,176