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 listJan 18, 2026 03:53Josu San MartinJosu San MartinScore: 9,035Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 18, 2026 03:539,011104,647,66058,001,00024,000,00094,662,656
2Jan 18, 2026 03:539,016111,139,06456,034,00026,016,00094,666,752
3Jan 18, 2026 03:539,031108,745,35354,119,00028,061,00094,666,752
4Jan 18, 2026 03:539,034114,299,42054,138,00028,071,00094,654,464
5Jan 18, 2026 03:539,035110,914,61558,157,00024,065,00094,715,904
6Jan 18, 2026 03:539,039103,783,68457,180,00025,079,00094,662,656
7Jan 18, 2026 03:539,047111,250,90058,234,00024,097,00094,646,272
8Jan 18, 2026 03:539,048107,877,74957,233,00025,102,00094,666,752
9Jan 18, 2026 03:539,108113,149,19156,919,00025,963,00094,633,984