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 22:46Andrew EpsteinAndrew EpsteinScore: 3,258Success
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 23:143,25140,507,21921,168,0008,423,00092,712,960
2Sep 14, 2026 23:143,25140,509,81121,165,0008,425,00092,774,400
3Sep 14, 2026 23:143,25539,919,04621,205,0008,423,00092,737,536
4Sep 14, 2026 23:143,25642,214,37321,162,0008,474,00092,700,672
5Sep 14, 2026 23:143,25839,909,55221,187,0008,464,00092,749,824
6Sep 14, 2026 23:143,26539,918,26421,245,0008,473,00092,712,960
7Sep 14, 2026 23:143,27239,986,38221,252,0008,527,00092,753,920
8Sep 14, 2026 23:143,27740,050,34921,291,0008,538,00092,733,440
9Sep 14, 2026 23:143,28040,085,96521,303,0008,546,00092,712,960