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 25, 2026 11:59Kevin HeaveyKevin HeaveyError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 25, 2026 12:00056,011,47045,822,000020,480Exit with code 3: ord:11:199867,27:800133, idlz=0 clen=2:998668, cd=0:99772,1:99570,2:99923,3:99696,4:100257,5:99812,6:99964,7:99803,8:100195,9:99676, nlen=10:998668, nlz=0 maxrec=192 minrec=69 n=136520347 hd=0,100301,99984,100447,99841,100189,99401,99...stderr