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 23:57Andrew EpsteinAndrew EpsteinScore: 3,047Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 15, 2026 00:033,01437,782,38318,903,0008,526,00092,745,728
2Sep 15, 2026 00:033,02637,809,26019,006,0008,537,00092,778,496
3Sep 15, 2026 00:033,03137,954,65019,023,0008,567,00092,692,480
4Sep 15, 2026 00:033,04138,636,88919,101,0008,581,00092,708,864
5Sep 15, 2026 00:033,04738,028,95619,112,0008,617,00092,753,920
6Sep 15, 2026 00:033,05938,114,59019,214,0008,626,00092,749,824
7Sep 15, 2026 00:033,06138,135,02519,283,0008,575,00092,753,920
8Sep 15, 2026 00:033,06638,317,15819,188,0008,714,00092,766,208
9Sep 15, 2026 00:033,06738,970,70819,206,0008,712,00092,774,400