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 listApr 29, 2026 12:44TudyMTudyMScore: 14,795Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 29, 2026 12:4614,765153,382,161111,473,00022,891,00094,593,024
2Apr 29, 2026 12:4614,774154,008,866110,548,00023,902,00094,638,080
3Apr 29, 2026 12:4614,777153,732,727109,571,00024,902,00094,593,024
4Apr 29, 2026 12:4614,789155,127,633109,660,00024,922,00094,633,984
5Apr 29, 2026 12:4614,795151,440,734108,711,00025,931,00094,621,696
6Apr 29, 2026 12:4614,837154,929,218112,018,00023,003,00094,625,792
7Apr 29, 2026 12:4614,855152,781,994116,163,00019,026,00094,625,792
8Apr 29, 2026 12:4614,921155,608,236116,815,00018,970,00094,674,944
9Apr 29, 2026 12:4615,074158,326,195112,144,00025,032,00094,633,984