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 04:28olliecrowolliecrowScore: 8,293Success
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 04:288,241101,065,86857,996,00016,998,00094,572,544
2Mar 4, 2026 04:288,256102,201,58958,101,00017,029,00094,547,968
3Mar 4, 2026 04:288,275100,698,60358,235,00017,069,00094,547,968
4Mar 4, 2026 04:288,283101,735,52658,289,00017,084,00094,547,968
5Mar 4, 2026 04:288,293106,006,42756,597,00018,865,00094,572,544
6Mar 4, 2026 04:288,304105,972,84958,661,00016,902,00094,552,064
7Mar 4, 2026 04:288,306105,071,71158,677,00016,907,00094,568,448
8Mar 4, 2026 04:288,307104,233,33360,677,00014,920,00094,572,544
9Mar 4, 2026 04:288,325102,590,73359,811,00015,949,00094,572,544