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 21, 2026 15:09limanjun99limanjun99Score: 3,112Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 15:113,08844,592,48518,066,00010,036,00092,971,008
2Apr 21, 2026 15:113,09844,747,31518,128,00010,071,00093,163,520
3Apr 21, 2026 15:113,10343,804,44920,174,0008,069,00093,130,752
4Apr 21, 2026 15:113,11046,626,60020,220,0008,088,00093,134,848
5Apr 21, 2026 15:113,11244,547,78718,206,00010,114,00093,167,616
6Apr 21, 2026 15:113,12345,587,95920,302,0008,120,00093,130,752
7Apr 21, 2026 15:113,12645,253,80818,290,00010,161,00093,175,808
8Apr 21, 2026 15:113,12646,119,93617,275,00011,178,00093,188,096
9Apr 21, 2026 15:113,14450,398,48017,761,00010,854,00093,208,576