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 listAug 15, 2026 22:09marko1597marko1597Score: 3,634Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 15, 2026 22:253,62249,314,03724,615,0008,348,00092,737,536stderr
2Aug 15, 2026 22:253,62242,110,83624,609,0008,355,00092,745,728stderr
3Aug 15, 2026 22:253,62242,007,58224,633,0008,335,00092,758,016stderr
4Aug 15, 2026 22:253,63250,709,22824,688,0008,368,00092,733,440stderr
5Aug 15, 2026 22:253,63442,104,68124,678,0008,397,00092,712,960stderr
6Aug 15, 2026 22:253,63942,144,87424,651,0008,465,00092,819,456stderr
7Aug 15, 2026 22:253,65642,395,11924,843,0008,435,00092,803,072stderr
8Aug 15, 2026 22:253,65642,394,29824,900,0008,372,00092,741,632stderr
9Aug 15, 2026 22:253,67242,475,86624,956,0008,468,00092,745,728stderr