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 21, 2026 02:09Dominique GarmierDominique GarmierScore: 11,600Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 21, 2026 04:0011,516132,618,58687,988,00016,806,00094,793,728
2Mar 19, 2026 17:0811,522130,827,96585,875,00018,972,00094,564,352
3Mar 16, 2026 11:0311,524125,483,40384,896,00019,975,00094,564,352
4Mar 16, 2026 11:0311,525136,069,90584,900,00019,976,00094,797,824
5Mar 19, 2026 17:0811,528130,977,75385,922,00018,982,00094,539,776
6Mar 21, 2026 04:0011,543128,835,60985,031,00020,007,00094,543,872
7Mar 16, 2026 11:0311,567132,037,99688,218,00017,042,00094,797,824
8Mar 16, 2026 11:0311,583130,279,32787,339,00018,070,00094,564,352
9Mar 16, 2026 11:0311,600132,307,43985,642,00019,916,00094,564,352
10Mar 21, 2026 04:0011,600133,246,08583,445,00022,118,00094,547,968
11Mar 16, 2026 11:0311,604130,423,19385,675,00019,924,00094,785,536
12Mar 16, 2026 11:0311,616132,544,59787,759,00017,950,00094,633,984
13Mar 16, 2026 11:0311,622134,005,83886,804,00018,957,00094,539,776
14Mar 16, 2026 11:0311,623138,416,66588,806,00016,963,00094,564,352
15Mar 21, 2026 02:0911,637127,500,44885,919,00019,981,00094,765,056
16Mar 19, 2026 17:0811,651133,562,14089,017,00017,003,00094,539,776
17Mar 21, 2026 02:0911,798150,769,97888,473,00018,887,00094,556,160
18Mar 21, 2026 02:0911,848147,749,40888,846,00018,967,00094,547,968