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 3, 2026 16:08TudyMTudyMScore: 8,660Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2026 16:238,63293,286,70162,026,00016,527,00094,646,272
2May 3, 2026 16:238,63995,427,36161,914,00016,705,00094,638,080
3May 3, 2026 16:238,65394,665,71762,274,00016,469,00094,642,176
4May 3, 2026 16:238,65894,031,66762,146,00016,648,00094,642,176
5May 3, 2026 16:238,66095,157,95661,469,00017,344,00094,625,792
6May 3, 2026 16:238,66694,297,92862,381,00016,483,00094,625,792
7May 3, 2026 16:238,69894,435,11961,538,00017,620,00094,638,080
8May 3, 2026 16:238,73195,395,02662,258,00017,202,00094,625,792
9May 3, 2026 16:238,74495,094,14662,329,00017,246,00094,625,792