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 18:24highload-churnerhighload-churnerScore: 2,506Success
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 18:322,49831,836,63014,296,0008,443,00092,762,112
2Oct 15, 2026 18:322,50131,805,85514,415,0008,352,00092,749,824
3Oct 15, 2026 18:322,50231,894,30114,458,0008,319,00092,717,056
4Oct 15, 2026 18:322,50531,961,25714,347,0008,451,00092,696,576
5Oct 15, 2026 18:322,50631,886,38814,385,0008,421,00092,737,536
6Oct 15, 2026 18:322,50731,848,71514,378,0008,441,00092,790,784
7Oct 15, 2026 18:322,50731,941,91014,384,0008,437,00092,766,208
8Oct 15, 2026 18:322,52131,952,96114,366,0008,582,00092,725,248
9Oct 15, 2026 18:322,53332,174,95314,378,0008,680,00092,758,016