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 listNov 3, 2026 04:18Andrew EpsteinAndrew EpsteinScore: 2,766Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 04:242,74835,902,15416,532,0008,483,00092,688,384
2Nov 3, 2026 04:242,75136,144,49716,560,0008,476,00092,786,688
3Nov 3, 2026 04:242,76236,422,87116,543,0008,599,00092,721,152
4Nov 3, 2026 04:242,76536,026,86316,651,0008,516,00092,729,344
5Nov 3, 2026 04:242,76636,478,66416,585,0008,589,00092,749,824
6Nov 3, 2026 04:242,76736,489,22416,681,0008,500,00092,688,384
7Nov 3, 2026 04:242,77536,125,59416,686,0008,574,00092,708,864
8Nov 3, 2026 04:242,77936,108,48816,726,0008,567,00092,762,112
9Nov 3, 2026 04:242,80236,834,37416,858,0008,642,00092,676,096