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 18, 2026 04:54M-RochatM-RochatScore: 6,915Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 05:056,90371,922,00454,467,0008,354,00092,827,648
2May 18, 2026 05:056,91073,988,22854,507,0008,376,00092,790,784
3May 18, 2026 05:056,91172,033,96054,558,0008,340,00092,680,192
4May 18, 2026 05:056,91472,223,50154,606,0008,320,00092,712,960
5May 18, 2026 05:056,91572,001,82754,514,0008,420,00092,741,632
6May 18, 2026 05:056,92674,031,95254,587,0008,441,00092,758,016
7May 18, 2026 05:056,92772,162,97654,545,0008,494,00092,753,920
8May 18, 2026 05:056,94172,359,82554,687,0008,481,00092,827,648
9May 18, 2026 05:056,94574,329,42854,744,0008,459,00092,721,152