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 21:29Charles CabergsCharles CabergsScore: 3,998Success
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 21:303,96854,128,11316,051,00020,064,00094,801,920
2Apr 29, 2026 21:303,97553,635,17917,085,00019,095,00094,793,728
3Apr 29, 2026 21:303,98752,193,10119,153,00017,137,00094,789,632
4Apr 29, 2026 21:303,99452,627,05319,186,00017,166,00094,801,920
5Apr 29, 2026 21:303,99851,391,62119,203,00017,182,00094,593,024
6Apr 29, 2026 21:304,00554,813,01320,248,00016,198,00094,789,632
7Apr 29, 2026 21:304,01452,987,06920,296,00016,237,00094,609,408
8Apr 29, 2026 21:304,04456,841,38117,382,00019,427,00094,629,888
9Apr 29, 2026 21:304,05057,127,30915,939,00020,921,00094,793,728