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 listSep 16, 2026 14:47Victor MerckléVictor MerckléScore: 2,714Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 16, 2026 14:522,69333,311,22115,896,0008,614,00092,766,208stderr
2Sep 16, 2026 14:522,70133,307,60615,907,0008,675,00092,745,728stderr
3Sep 16, 2026 14:522,70833,362,01916,004,0008,645,00092,737,536stderr
4Sep 16, 2026 14:522,71233,408,86415,984,0008,703,00092,762,112stderr
5Sep 16, 2026 14:522,71433,492,30915,958,0008,745,00092,712,960stderr
6Sep 16, 2026 14:522,71633,447,11815,971,0008,747,00092,749,824stderr
7Sep 16, 2026 14:522,71733,489,98316,006,0008,723,00092,753,920stderr
8Sep 16, 2026 14:522,71733,420,22715,973,0008,753,00092,782,592stderr
9Sep 16, 2026 14:522,72733,607,91416,004,0008,819,00092,762,112stderr