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 listOct 15, 2026 14:06highload-churnerhighload-churnerScore: 2,599Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 15, 2026 14:122,58532,536,58715,213,0008,317,00092,790,784
2Oct 15, 2026 14:122,59032,592,22415,237,0008,333,00092,717,056
3Oct 15, 2026 14:122,59332,617,51915,254,0008,346,00092,737,536
4Oct 15, 2026 14:122,59432,520,36115,314,0008,299,00092,745,728
5Oct 15, 2026 14:122,59934,431,16215,256,0008,395,00092,815,360
6Oct 15, 2026 14:122,61332,825,43015,307,0008,479,00092,753,920
7Oct 15, 2026 14:122,61632,888,45215,149,0008,663,00092,712,960
8Oct 15, 2026 14:122,61932,939,94715,377,0008,461,00092,717,056
9Oct 15, 2026 14:122,61932,845,47415,412,0008,423,00092,770,304