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:13Andrew EpsteinAndrew EpsteinScore: 4,079Success
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 22:404,07247,317,69928,994,0008,065,00092,753,920
2Sep 14, 2026 22:404,07347,344,13928,407,0008,661,00092,721,152
3Sep 14, 2026 22:404,07647,419,05928,889,0008,207,00092,704,768
4Sep 14, 2026 22:404,07947,337,44728,844,0008,280,00092,729,344
5Sep 14, 2026 22:404,07947,336,97228,720,0008,402,00092,758,016
6Sep 14, 2026 22:404,08247,314,02228,871,0008,279,00092,704,768
7Sep 14, 2026 22:404,08647,439,30528,918,0008,271,00092,721,152
8Sep 14, 2026 22:404,08947,449,26628,379,0008,838,00092,721,152
9Sep 14, 2026 22:404,09647,604,02728,917,0008,365,00092,786,688