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 listNov 5, 2026 05:06Andrew EpsteinAndrew EpsteinScore: 2,368Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 05:422,33930,581,12112,844,0008,446,00092,741,632
2Nov 5, 2026 05:422,35330,683,27312,885,0008,535,00092,708,864
3Nov 5, 2026 05:422,36330,845,46612,960,0008,551,00092,741,632
4Nov 5, 2026 05:422,36730,868,97113,114,0008,431,00092,741,632
5Nov 5, 2026 05:422,36831,367,28613,116,0008,434,00092,733,440
6Nov 5, 2026 05:422,37430,899,38413,108,0008,497,00092,766,208
7Nov 5, 2026 05:422,37730,900,04513,164,0008,474,00092,770,304
8Nov 5, 2026 05:422,38831,025,87213,144,0008,587,00092,803,072
9Nov 5, 2026 05:422,39031,632,57713,283,0008,472,00092,753,920