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 20, 2026 19:46Dominique GarmierDominique GarmierScore: 862,521Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 20, 2026 19:46859,3307,856,918,4947,769,952,00049,954,00094,756,864
2Mar 13, 2026 11:52859,7557,854,330,4257,776,824,00046,950,00094,588,928
3Mar 13, 2026 11:52860,4707,868,092,9347,784,325,00045,954,00094,797,824
4Mar 20, 2026 15:05860,4937,859,521,1897,777,530,00052,955,00094,674,944
5Mar 20, 2026 16:55860,6727,864,745,8327,786,156,00045,959,00094,818,304
6Mar 13, 2026 11:52861,0887,873,762,3667,794,941,00040,957,00094,810,112
7Mar 20, 2026 15:05861,5027,875,675,9437,781,730,00057,938,00094,752,768
8Mar 13, 2026 11:52861,7847,876,641,2087,796,277,00045,954,00094,580,736
9Mar 20, 2026 15:05862,3517,881,841,7697,796,448,00050,944,00094,597,120
10Mar 13, 2026 11:52862,5217,884,550,3367,806,979,00041,962,00094,711,808
11Mar 20, 2026 16:55862,6407,888,635,4417,803,075,00046,946,00094,707,712
12Mar 13, 2026 11:52862,9007,878,860,9457,797,440,00054,953,00094,580,736
13Mar 20, 2026 19:46863,3147,890,793,1457,822,190,00033,966,00094,744,576
14Mar 13, 2026 11:52863,9927,896,964,8947,819,368,00042,958,00094,748,672
15Mar 20, 2026 16:55865,1747,906,096,8967,824,131,00048,950,00094,699,520
16Mar 13, 2026 11:52865,8517,915,659,2607,821,298,00057,942,00094,785,536
17Mar 13, 2026 11:52867,5967,930,225,2427,844,180,00050,942,00094,584,832
18Mar 20, 2026 19:46875,2128,003,398,4617,910,480,00053,948,00094,711,808