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 13, 2026 14:38highload-churnerhighload-churnerScore: 6,801Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 13, 2026 14:446,78670,761,78953,510,0008,249,00092,749,824
2Oct 13, 2026 14:446,79770,864,69453,492,0008,366,00092,807,168
3Oct 13, 2026 14:446,79870,841,44453,544,0008,319,00092,762,112
4Oct 13, 2026 14:446,79970,861,19253,475,0008,398,00092,749,824
5Oct 13, 2026 14:446,80170,848,60953,530,0008,362,00092,745,728
6Oct 13, 2026 14:446,80270,996,62953,535,0008,370,00092,721,152
7Oct 13, 2026 14:446,80670,979,31653,480,0008,462,00092,721,152
8Oct 13, 2026 14:446,80770,935,87753,573,0008,377,00092,758,016
9Oct 13, 2026 14:446,81571,041,78453,653,0008,368,00092,758,016