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 21, 2026 16:26M-RochatM-RochatScore: 5,981Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 21, 2026 16:325,94764,169,34137,744,00016,374,00094,392,320
2May 21, 2026 16:325,94964,754,58637,741,00016,398,00094,392,320
3May 21, 2026 16:325,95566,343,63137,725,00016,467,00094,392,320
4May 21, 2026 16:325,96763,528,68337,786,00016,522,00094,392,320
5May 21, 2026 16:325,98164,675,17237,803,00016,630,00094,392,320
6May 21, 2026 16:325,98464,185,13737,265,00017,195,00094,392,320
7May 21, 2026 16:325,99463,768,71437,914,00016,637,00094,392,320
8May 21, 2026 16:325,99863,798,15837,312,00017,277,00094,392,320
9May 21, 2026 16:326,00664,001,64937,844,00016,817,00094,392,320