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 listApr 29, 2026 13:12TudyMTudyMScore: 14,168Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 29, 2026 13:1414,132145,925,759105,674,00022,929,00094,621,696
2Apr 29, 2026 13:1414,136145,484,957105,707,00022,936,00094,584,832
3Apr 29, 2026 13:1414,138145,005,945103,728,00024,934,00094,629,888
4Apr 29, 2026 13:1414,150143,952,380106,808,00021,960,00094,625,792
5Apr 29, 2026 13:1414,168147,872,800106,948,00021,989,00094,629,888
6Apr 29, 2026 13:1414,187143,383,262106,091,00023,019,00094,756,864
7Apr 29, 2026 13:1414,192149,630,761105,121,00024,027,00094,629,888
8Apr 29, 2026 13:1414,217148,015,634108,316,00021,061,00094,629,888
9Apr 29, 2026 13:1414,363151,685,426106,764,00023,947,00094,625,792