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 29, 2026 12:52TudyMTudyMScore: 14,973Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 29, 2026 12:5414,819154,504,390113,879,00020,977,00094,629,888
2Apr 29, 2026 12:5414,836153,113,784110,196,00024,819,00094,633,984
3Apr 29, 2026 12:5414,852148,889,660112,129,00023,026,00094,699,520
4Apr 29, 2026 12:5414,900155,846,807111,668,00023,929,00094,625,792
5Apr 29, 2026 12:5414,973151,505,782112,215,00024,046,00094,633,984
6Apr 29, 2026 12:5414,986155,956,065112,485,00023,890,00094,638,080
7Apr 29, 2026 12:5415,048154,323,429112,134,00024,808,00094,633,984
8Apr 29, 2026 12:5415,110154,992,018111,599,00025,907,00094,588,928
9Apr 29, 2026 12:5415,203152,983,823112,476,00025,879,00094,629,888