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 5, 2026 00:10Victor MerckléVictor MerckléScore: 2,379Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 00:252,36830,602,90913,100,0008,457,00092,745,728stderr
2Sep 5, 2026 00:252,37129,862,95213,109,0008,471,00092,770,304stderr
3Sep 5, 2026 00:252,37330,643,93113,011,0008,585,00092,729,344stderr
4Sep 5, 2026 00:252,37330,643,39312,982,0008,619,00092,749,824stderr
5Sep 5, 2026 00:252,37930,048,05413,156,0008,499,00092,774,400stderr
6Sep 5, 2026 00:252,38730,130,87213,259,0008,464,00092,745,728stderr
7Sep 5, 2026 00:252,38830,694,04113,206,0008,525,00092,790,784stderr
8Sep 5, 2026 00:252,39030,758,85313,135,0008,623,00092,786,688stderr
9Sep 5, 2026 00:252,39632,334,11513,195,0008,611,00092,745,728stderr