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 21:44highload-churnerhighload-churnerScore: 6,348Success
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 22:062,36430,455,43213,025,0008,492,00091,758,592
2Oct 15, 2026 22:062,40030,787,07913,195,0008,648,00091,738,112
3Oct 15, 2026 22:062,88635,352,36514,794,00011,476,00091,791,360
4Oct 15, 2026 22:063,40849,874,00816,785,00014,236,00091,791,360
5Oct 15, 2026 22:066,34866,842,06529,058,00028,717,00091,934,720
6Oct 15, 2026 22:066,49078,209,91129,120,00029,942,00091,934,720
7Oct 15, 2026 22:066,53768,595,74628,531,00030,963,00091,947,008
8Oct 15, 2026 22:066,68669,857,66329,112,00031,734,00091,955,200
9Oct 15, 2026 22:066,84982,699,57529,209,00033,125,00091,955,200