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 00:27olliecrowolliecrowScore: 11,788Success
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 01:1111,728130,701,30289,769,00016,956,00094,568,448
2Mar 4, 2026 01:1111,748130,649,02489,920,00016,985,00094,572,544
3Mar 4, 2026 01:1111,758130,665,62688,998,00017,999,00094,572,544
4Mar 4, 2026 01:1111,758135,041,71689,002,00018,000,00094,547,968
5Mar 4, 2026 00:2711,764132,710,09790,045,00017,008,00094,572,544
6Mar 4, 2026 01:1111,779132,666,81890,162,00017,030,00094,568,448
7Mar 4, 2026 01:1111,788136,156,70792,231,00015,037,00094,547,968
8Mar 4, 2026 01:1111,793131,149,87789,263,00018,053,00094,547,968
9Mar 4, 2026 00:2711,803134,355,83490,340,00017,064,00094,572,544
10Mar 4, 2026 01:1111,805129,399,50791,514,00015,915,00094,556,160
11Mar 4, 2026 00:2711,814139,897,31789,589,00017,917,00094,568,448
12Mar 4, 2026 01:1111,829133,006,36490,704,00016,944,00094,547,968