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 20:54Andrew EpsteinAndrew EpsteinScore: 3,324Success
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 21:043,31440,487,73921,739,0008,427,00092,721,152
2Sep 14, 2026 21:043,31540,452,02021,732,0008,436,00092,778,496
3Sep 14, 2026 21:043,31940,599,62521,777,0008,429,00092,770,304
4Sep 14, 2026 21:043,32340,581,71421,785,0008,456,00092,737,536
5Sep 14, 2026 21:043,32440,603,18021,765,0008,485,00092,778,496
6Sep 14, 2026 21:043,33740,629,29121,826,0008,545,00092,721,152
7Sep 14, 2026 21:043,34040,803,01921,821,0008,574,00092,774,400
8Sep 14, 2026 21:043,34240,702,23221,860,0008,559,00092,770,304
9Sep 14, 2026 21:043,34341,446,14421,733,0008,689,00092,745,728