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 listMay 3, 2026 15:59Victor MerckléVictor MerckléScore: 3,291Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 16:123,27146,144,16121,186,0008,585,00093,011,968
2May 3, 2026 16:123,27946,205,02521,232,0008,608,00092,971,008
3May 3, 2026 16:123,28044,591,81821,212,0008,636,00092,991,488
4May 3, 2026 16:123,29044,813,66521,268,0008,678,00093,048,832
5May 3, 2026 16:123,29148,168,86521,244,0008,708,00093,052,928
6May 3, 2026 16:123,29146,413,79021,221,0008,730,00092,979,200
7May 3, 2026 16:123,30846,677,82521,398,0008,705,00093,011,968
8May 3, 2026 16:123,31344,178,55321,347,0008,804,00092,983,296
9May 3, 2026 16:123,31746,599,65721,383,0008,809,00093,081,600