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 14:51TudyMTudyMScore: 11,345Success
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 15:0111,293117,826,20185,712,00017,060,00094,646,272
2May 3, 2026 15:0111,310120,078,11685,717,00017,213,00094,638,080
3May 3, 2026 15:0111,326119,543,27185,598,00017,476,00094,633,984
4May 3, 2026 15:0111,327120,093,72885,400,00017,684,00094,617,600
5May 3, 2026 15:0111,345119,935,81585,411,00017,830,00094,638,080
6May 3, 2026 15:0111,357120,039,12685,679,00017,670,00094,638,080
7May 3, 2026 15:0111,369119,248,24586,107,00017,355,00094,633,984
8May 3, 2026 15:0111,389118,524,36286,389,00017,257,00094,638,080
9May 3, 2026 15:0111,465120,320,46186,222,00018,117,00094,625,792