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 16:24TudyMTudyMScore: 8,560Success
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 16:348,50097,108,37460,930,00016,420,00094,650,368
2May 3, 2026 16:348,54193,275,39860,978,00016,752,00094,625,792
3May 3, 2026 16:348,54694,003,58061,275,00016,502,00094,633,984
4May 3, 2026 16:348,55394,257,46461,101,00016,740,00094,646,272
5May 3, 2026 16:348,56094,862,30360,378,00017,524,00094,633,984
6May 3, 2026 16:348,56295,851,55560,384,00017,537,00094,642,176
7May 3, 2026 16:348,56492,189,38861,487,00016,451,00094,633,984
8May 3, 2026 16:348,56897,791,90260,638,00017,336,00094,633,984
9May 3, 2026 16:348,57091,997,87061,244,00016,743,00094,629,888