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 07:41highload-churnerhighload-churnerScore: 3,107Success
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 07:473,09737,134,03019,696,0008,490,00092,692,480
2Oct 15, 2026 07:473,09737,022,75219,689,0008,502,00092,770,304
3Oct 15, 2026 07:473,10237,128,69419,698,0008,534,00092,708,864
4Oct 15, 2026 07:473,10437,139,86819,698,0008,551,00092,770,304
5Oct 15, 2026 07:473,10737,129,83619,695,0008,582,00092,753,920
6Oct 15, 2026 07:473,11337,319,09519,701,0008,634,00092,745,728
7Oct 15, 2026 07:473,11537,947,13619,734,0008,617,00092,753,920
8Oct 15, 2026 07:473,12037,236,19519,741,0008,652,00092,794,880
9Oct 15, 2026 07:473,12538,093,29919,738,0008,706,00092,778,496