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 18:07TudyMTudyMScore: 8,388Success
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:128,30592,492,73157,930,00017,647,00094,625,792
2May 3, 2026 18:128,38292,128,52659,315,00016,969,00094,642,176
3May 3, 2026 18:128,38492,152,18458,622,00017,680,00094,625,792
4May 3, 2026 18:128,38692,338,43058,953,00017,365,00094,633,984
5May 3, 2026 18:128,38892,123,13258,859,00017,475,00094,633,984
6May 3, 2026 18:128,38895,838,69958,700,00017,632,00094,597,120
7May 3, 2026 18:128,38990,499,46058,777,00017,567,00094,633,984
8May 3, 2026 18:128,39791,484,05259,457,00016,963,00094,633,984
9May 3, 2026 18:128,40090,215,39159,607,00016,837,00094,638,080