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 04:55olliecrowolliecrowScore: 4,524Success
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 04:574,39561,418,14622,994,00016,996,00094,547,968
2Mar 20, 2026 04:534,41167,116,69023,079,00017,058,00094,552,064
3Mar 20, 2026 04:574,42369,416,75824,152,00016,101,00094,564,352
4Mar 20, 2026 04:574,42467,734,25021,134,00019,121,00094,564,352
5Mar 20, 2026 04:534,42566,446,60020,132,00020,132,00094,564,352
6Mar 20, 2026 04:534,46968,119,76220,830,00019,838,00094,556,160
7Mar 20, 2026 04:454,52469,952,73923,524,00017,643,00094,556,160
8Mar 20, 2026 04:454,55469,519,27227,293,00014,151,00094,556,160
9Mar 20, 2026 04:454,61171,108,47428,975,00012,989,00094,564,352
10Mar 20, 2026 04:554,73272,215,14825,038,00018,027,00094,564,352
11Mar 20, 2026 04:554,74973,867,35126,131,00017,086,00094,552,064
12Mar 20, 2026 04:554,77676,037,36426,280,00017,183,00094,543,872