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 listMay 17, 2026 02:30M-RochatM-RochatScore: 9,010Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 17, 2026 02:418,98990,679,40665,365,00016,438,00094,392,320
2May 17, 2026 02:418,99290,514,69765,418,00016,415,00094,392,320
3May 17, 2026 02:418,99693,763,07464,821,00017,048,00094,392,320
4May 17, 2026 02:419,00093,536,80364,850,00017,053,00094,392,320
5May 17, 2026 02:419,01091,228,99865,489,00016,506,00094,392,320
6May 17, 2026 02:419,01290,801,72064,902,00017,110,00094,392,320
7May 17, 2026 02:419,01790,812,51264,933,00017,129,00094,392,320
8May 17, 2026 02:419,04199,625,69765,078,00017,197,00094,392,320
9May 17, 2026 02:419,14592,031,04366,708,00016,512,00094,392,320