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 28, 2026 10:07TudyMTudyMScore: 16,542Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 10:1016,498167,652,798126,118,00024,022,00094,625,792
2Apr 28, 2026 10:1016,512167,910,571126,381,00023,883,00094,638,080
3Apr 28, 2026 10:1016,536170,424,103129,553,00020,927,00094,633,984
4Apr 28, 2026 10:1016,542168,335,599126,609,00023,926,00094,642,176
5Apr 28, 2026 10:1016,542170,680,164126,613,00023,927,00094,584,832
6Apr 28, 2026 10:1016,555167,289,820128,709,00021,950,00094,703,616
7Apr 28, 2026 10:1016,561168,839,573127,755,00022,956,00094,584,832
8Apr 28, 2026 10:1016,568165,145,945126,811,00023,964,00094,633,984
9Apr 28, 2026 10:1016,773172,709,283126,699,00025,938,00094,642,176