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:25Victor MerckléVictor MerckléScore: 3,407Success
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:313,39239,574,82822,477,0008,394,00092,717,056stderr
2Sep 15, 2026 09:313,39839,584,14822,664,0008,258,00092,745,728stderr
3Sep 15, 2026 09:313,40139,630,11122,555,0008,400,00092,721,152stderr
4Sep 15, 2026 09:313,40340,319,43422,672,0008,303,00092,708,864stderr
5Sep 15, 2026 09:313,40740,394,02722,684,0008,320,00092,729,344stderr
6Sep 15, 2026 09:313,40839,757,73922,657,0008,364,00092,745,728stderr
7Sep 15, 2026 09:313,41140,377,58022,508,0008,536,00092,721,152stderr
8Sep 15, 2026 09:313,42040,519,55722,706,0008,416,00092,721,152stderr
9Sep 15, 2026 09:313,42150,205,24222,719,0008,418,00092,758,016stderr