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 05:50olliecrowolliecrowScore: 8,254Success
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 05:508,221101,063,14857,855,00016,957,00094,572,544
2Mar 4, 2026 05:508,23398,544,84457,938,00016,982,00094,568,448
3Mar 4, 2026 05:508,24696,552,27557,029,00018,009,00094,552,064
4Mar 4, 2026 05:508,25299,073,88259,075,00016,020,00094,560,256
5Mar 4, 2026 05:508,254102,345,67658,083,00017,024,00094,556,160
6Mar 4, 2026 05:508,27699,217,43258,243,00017,071,00094,556,160
7Mar 4, 2026 05:508,277106,166,41256,490,00018,830,00094,572,544
8Mar 4, 2026 05:508,292101,530,88858,582,00016,879,00094,552,064
9Mar 4, 2026 05:508,310102,285,65956,714,00018,904,00094,552,064