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 listApr 28, 2026 16:28Charles CabergsCharles CabergsScore: 4,200Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 16:304,19459,146,24421,092,00017,075,00094,801,920
2Apr 28, 2026 16:304,19458,222,34820,091,00018,082,00094,609,408
3Apr 28, 2026 16:304,19552,210,05621,099,00017,080,00094,793,728
4Apr 28, 2026 16:304,19558,762,16017,081,00021,100,00094,785,536
5Apr 28, 2026 16:304,20055,701,80720,117,00018,105,00094,797,824
6Apr 28, 2026 16:304,20952,704,47820,163,00018,146,00094,797,824
7Apr 28, 2026 16:304,22057,825,90621,227,00017,183,00094,793,728
8Apr 28, 2026 16:304,24555,602,76120,802,00017,831,00094,789,632
9Apr 28, 2026 16:304,24862,773,43119,828,00018,836,00094,793,728