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:21olliecrowolliecrowScore: 33,022Success
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:2132,961321,109,140279,952,00019,996,00094,564,352
2Mar 3, 2026 22:2132,998325,874,184280,330,00019,952,00094,560,256
3Mar 3, 2026 22:2132,999325,111,637271,361,00028,931,00094,564,352
4Mar 3, 2026 22:2133,013326,120,087280,458,00019,961,00094,543,872
5Mar 3, 2026 22:2133,022327,893,489287,481,00013,021,00094,564,352
6Mar 3, 2026 22:2133,050325,026,261280,770,00019,983,00094,547,968
7Mar 3, 2026 22:2133,175325,361,064285,899,00015,994,00094,543,872
8Mar 3, 2026 22:2133,267329,463,432286,743,00015,985,00094,564,352
9Mar 3, 2026 22:2133,645333,474,617290,162,00016,008,00094,793,728