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:11TudyMTudyMScore: 14,664Success
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:1514,610151,010,496107,961,00024,990,00094,769,152
2Apr 28, 2026 10:1514,657151,548,032108,495,00024,884,00094,584,832
3Apr 28, 2026 10:1514,660151,396,526110,508,00022,898,00094,597,120
4Apr 28, 2026 10:1514,660153,600,356109,516,00023,894,00094,638,080
5Apr 28, 2026 10:1514,664153,691,110110,539,00022,904,00094,633,984
6Apr 28, 2026 10:1514,666150,226,964110,558,00022,908,00094,638,080
7Apr 28, 2026 10:1514,688150,091,238110,725,00022,943,00094,629,888
8Apr 28, 2026 10:1514,730154,498,177111,042,00023,008,00094,625,792
9Apr 28, 2026 10:1514,934152,460,942109,926,00025,982,00094,629,888