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 06:24Josu San MartinJosu San MartinScore: 5,216Success
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 06:245,14369,989,99623,900,00022,904,00094,552,064
2Jan 18, 2026 06:245,18468,771,79530,111,00017,063,00094,666,752
3Jan 18, 2026 06:245,19676,131,79232,192,00015,090,00094,552,064
4Jan 18, 2026 06:245,19870,402,96332,207,00015,097,00094,552,064
5Jan 18, 2026 06:245,21677,784,52527,267,00020,198,00094,679,040
6Jan 18, 2026 06:245,22477,881,95726,299,00021,242,00094,679,040
7Jan 18, 2026 06:245,23578,461,83522,828,00024,813,00094,552,064
8Jan 18, 2026 06:245,24276,791,29926,833,00020,870,00094,679,040
9Jan 18, 2026 06:245,27477,594,23526,997,00020,998,00094,674,944