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 listAug 19, 2026 08:49Victor MerckléVictor MerckléScore: 3,093Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 19, 2026 08:553,07636,469,72719,547,0008,448,00092,782,592stderr
2Aug 19, 2026 08:553,08838,379,15819,609,0008,494,00092,741,632stderr
3Aug 19, 2026 08:553,08937,112,67619,623,0008,494,00092,753,920stderr
4Aug 19, 2026 08:553,09236,699,20519,585,0008,558,00092,725,248stderr
5Aug 19, 2026 08:553,09337,224,71519,548,0008,603,00092,774,400stderr
6Aug 19, 2026 08:553,09437,156,12019,577,0008,582,00092,749,824stderr
7Aug 19, 2026 08:553,09537,207,08019,642,0008,526,00092,737,536stderr
8Aug 19, 2026 08:553,09536,816,99019,580,0008,590,00092,762,112stderr
9Aug 19, 2026 08:553,10336,577,90519,553,0008,687,00092,729,344stderr