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 1, 2026 11:31Victor MerckléVictor MerckléScore: 7,476Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2026 11:337,44684,053,06248,830,00018,934,00094,593,024stderr
2May 1, 2026 11:337,46583,672,67350,952,00016,984,00094,654,464stderr
3May 1, 2026 11:337,46883,299,21248,971,00018,988,00094,638,080stderr
4May 1, 2026 11:337,47388,744,73452,008,00016,002,00094,650,368stderr
5May 1, 2026 11:337,47686,451,90552,026,00016,008,00094,728,192stderr
6May 1, 2026 11:337,48083,409,01050,050,00018,018,00094,650,368stderr
7May 1, 2026 11:337,48085,837,58751,051,00017,017,00094,601,216stderr
8May 1, 2026 11:337,49688,309,25752,169,00016,052,00094,601,216stderr
9May 1, 2026 11:337,51486,032,41655,306,00013,072,00094,646,272stderr