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 listSep 14, 2026 02:27Andrew EpsteinAndrew EpsteinScore: 3,348Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 02:403,33340,651,13721,893,0008,441,00092,708,864
2Sep 14, 2026 02:403,33340,699,19421,888,0008,445,00092,729,344
3Sep 14, 2026 02:403,34340,669,94121,847,0008,583,00092,696,576
4Sep 14, 2026 02:403,34540,717,16021,929,0008,519,00092,704,768
5Sep 14, 2026 02:403,34840,871,53021,821,0008,653,00092,696,576
6Sep 14, 2026 02:403,35240,884,97421,991,0008,518,00092,749,824
7Sep 14, 2026 02:403,35240,849,76721,831,0008,677,00092,729,344
8Sep 14, 2026 02:403,36140,997,45021,881,0008,707,00092,647,424
9Sep 14, 2026 02:403,36740,961,09121,866,0008,780,00092,745,728