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 5, 2026 06:43Victor MerckléVictor MerckléScore: 10,031Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 06:5310,021105,362,41469,337,00021,859,00094,642,176stderr
2May 5, 2026 06:5310,023107,776,49069,269,00021,941,00094,654,464stderr
3May 5, 2026 06:5310,024109,427,08169,450,00021,772,00094,642,176stderr
4May 5, 2026 06:5310,029105,755,80669,370,00021,896,00094,646,272stderr
5May 5, 2026 06:5310,031109,407,46569,438,00021,851,00094,638,080stderr
6May 5, 2026 06:5310,043109,507,75069,433,00021,960,00094,638,080stderr
7May 5, 2026 06:5310,051110,445,28269,401,00022,067,00094,646,272stderr
8May 5, 2026 06:5310,055108,770,32169,638,00021,864,00094,642,176stderr
9May 5, 2026 06:5310,056105,889,30869,333,00022,185,00094,633,984stderr