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 15, 2026 09:51Victor MerckléVictor MerckléScore: 2,922Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 09:562,91635,325,35017,959,0008,581,00092,823,552stderr
2Sep 15, 2026 09:562,91735,273,51617,969,0008,580,00092,672,000stderr
3Sep 15, 2026 09:562,92135,860,34017,958,0008,630,00092,753,920stderr
4Sep 15, 2026 09:562,92135,875,94717,979,0008,607,00092,737,536stderr
5Sep 15, 2026 09:562,92235,319,88517,953,0008,642,00092,717,056stderr
6Sep 15, 2026 09:562,93135,338,38117,975,0008,705,00092,737,536stderr
7Sep 15, 2026 09:562,93135,391,14617,976,0008,699,00092,708,864stderr
8Sep 15, 2026 09:562,93335,340,00717,986,0008,710,00092,737,536stderr
9Sep 15, 2026 09:562,93836,048,67418,079,0008,664,00092,700,672stderr