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 3, 2026 22:31olliecrowolliecrowScore: 16,036Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 3, 2026 22:3115,997172,311,878130,514,00015,059,00094,547,968
2Mar 3, 2026 22:3116,005174,687,226127,686,00017,955,00094,543,872
3Mar 3, 2026 22:3116,016169,535,223126,778,00018,966,00094,793,728
4Mar 3, 2026 22:3116,024170,901,574129,839,00015,980,00094,658,560
5Mar 3, 2026 22:3116,036173,470,734130,939,00014,993,00094,801,920
6Mar 3, 2026 22:3116,040169,993,115128,965,00016,995,00094,801,920
7Mar 3, 2026 22:3116,044170,623,517131,001,00015,000,00094,552,064
8Mar 3, 2026 22:3116,047173,653,966127,024,00019,003,00094,547,968
9Mar 3, 2026 22:3116,057171,765,540129,103,00017,013,00094,552,064