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 00:19olliecrowolliecrowScore: 4,543Success
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 00:154,51363,782,05125,043,00016,027,00094,552,064
2Mar 20, 2026 00:154,51366,446,80123,040,00018,031,00094,547,968
3Mar 20, 2026 00:154,51676,098,54723,055,00018,043,00094,552,064
4Mar 20, 2026 00:194,51865,717,23025,067,00016,043,00094,547,968
5Mar 20, 2026 00:154,52665,318,08328,127,00013,059,00094,552,064
6Mar 20, 2026 00:154,53562,361,52223,149,00018,117,00094,552,064
7Mar 20, 2026 00:154,54363,275,16727,224,00014,116,00094,552,064
8Mar 20, 2026 00:154,54364,249,13327,227,00014,117,00094,543,872
9Mar 20, 2026 00:194,54663,637,68625,227,00016,145,00094,552,064
10Mar 20, 2026 00:194,56572,912,65425,333,00016,213,00094,552,064
11Mar 20, 2026 00:154,58068,855,85723,815,00017,861,00094,662,656
12Mar 20, 2026 00:154,58265,946,21021,842,00019,857,00094,552,064