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 17:59TudyMTudyMScore: 8,512Success
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 18:058,45292,392,91059,455,00017,462,00094,629,888
2May 3, 2026 18:058,48390,752,94660,272,00016,931,00094,638,080
3May 3, 2026 18:058,48992,790,38759,743,00017,510,00094,633,984
4May 3, 2026 18:058,51193,314,29160,122,00017,332,00094,633,984
5May 3, 2026 18:058,51295,395,38360,493,00016,968,00094,642,176
6May 3, 2026 18:058,51594,248,77460,631,00016,860,00094,633,984
7May 3, 2026 18:058,53694,642,13760,093,00017,585,00094,646,272
8May 3, 2026 18:058,55291,596,60160,096,00017,729,00094,638,080
9May 3, 2026 18:058,55292,777,94460,878,00016,946,00094,625,792