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 19:49highload-churnerhighload-churnerScore: 2,494Success
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 19:552,47931,659,41614,229,0008,331,00092,737,536
2Oct 15, 2026 19:552,48231,743,63814,251,0008,339,00092,696,576
3Oct 15, 2026 19:552,48831,770,91914,271,0008,372,00092,770,304
4Oct 15, 2026 19:552,48931,734,94914,294,0008,357,00092,725,248
5Oct 15, 2026 19:552,49431,811,68014,402,0008,301,00092,737,536
6Oct 15, 2026 19:552,49632,299,27314,334,0008,380,00092,758,016
7Oct 15, 2026 19:552,49831,924,50014,303,0008,436,00092,745,728
8Oct 15, 2026 19:552,50031,824,69614,327,0008,424,00092,672,000
9Oct 15, 2026 19:552,51631,962,55414,301,0008,598,00092,717,056