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 16, 2026 03:29highload-churnerhighload-churnerScore: 2,399Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 16, 2026 03:372,38830,820,59113,274,0008,465,00092,692,480
2Oct 16, 2026 03:372,38930,815,90313,267,0008,476,00092,745,728
3Oct 16, 2026 03:372,39030,840,85613,269,0008,482,00092,721,152
4Oct 16, 2026 03:372,39830,849,11113,352,0008,478,00092,700,672
5Oct 16, 2026 03:372,39930,871,98213,326,0008,512,00092,758,016
6Oct 16, 2026 03:372,39930,884,10613,343,0008,494,00092,733,440
7Oct 16, 2026 03:372,40431,086,14313,296,0008,583,00092,729,344
8Oct 16, 2026 03:372,40630,912,10213,347,0008,548,00092,692,480
9Oct 16, 2026 03:372,41130,951,80413,375,0008,568,00092,733,440