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 listMay 18, 2026 06:44M-RochatM-RochatScore: 5,348Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 18, 2026 06:595,33658,335,62940,265,0008,297,00092,749,824
2May 18, 2026 06:595,33757,717,07440,310,0008,261,00092,745,728
3May 18, 2026 06:595,34358,735,66540,310,0008,320,00092,741,632
4May 18, 2026 06:595,34860,720,13940,281,0008,389,00092,790,784
5May 18, 2026 06:595,34858,234,99240,317,0008,354,00092,786,688
6May 18, 2026 06:595,34957,904,02040,225,0008,459,00092,758,016
7May 18, 2026 06:595,35159,116,93440,290,0008,406,00092,766,208
8May 18, 2026 06:595,35458,482,19840,296,0008,430,00092,749,824
9May 18, 2026 06:595,36557,936,85140,379,0008,451,00092,696,576