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 15:20Victor MerckléVictor MerckléScore: 2,716Success
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 15:282,70333,304,46615,903,0008,695,00092,762,112stderr
2Sep 15, 2026 15:282,71234,030,77416,113,0008,575,00092,684,288stderr
3Sep 15, 2026 15:282,71333,377,17516,100,0008,592,00092,741,632stderr
4Sep 15, 2026 15:282,71634,104,39116,096,0008,628,00092,794,880stderr
5Sep 15, 2026 15:282,71633,397,84615,965,0008,752,00092,778,496stderr
6Sep 15, 2026 15:282,71734,100,92216,106,0008,622,00092,745,728stderr
7Sep 15, 2026 15:282,72533,555,08716,115,0008,683,00092,774,400stderr
8Sep 15, 2026 15:282,72634,212,98716,112,0008,698,00092,721,152stderr
9Sep 15, 2026 15:282,72833,538,70316,125,0008,701,00092,717,056stderr