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 listApr 22, 2026 09:01olliecrowolliecrowScore: 5,246Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 09:035,22966,582,45331,724,00015,862,00094,633,984
2Apr 22, 2026 09:035,23963,851,86928,806,00018,873,00094,642,176
3Apr 22, 2026 09:035,24067,076,92428,814,00018,878,00094,617,600
4Apr 22, 2026 09:035,24475,259,25524,857,00022,868,00094,609,408
5Apr 22, 2026 09:035,24666,099,76228,844,00018,898,00094,625,792
6Apr 22, 2026 09:035,24666,093,86331,830,00015,915,00094,629,888
7Apr 22, 2026 09:035,25068,617,42326,876,00020,904,00094,633,984
8Apr 22, 2026 09:035,25562,983,53924,911,00022,918,00094,625,792
9Apr 22, 2026 09:035,26864,519,74026,968,00020,975,00094,629,888