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 21:26Andrew EpsteinAndrew EpsteinScore: 4,246Success
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 21:464,22748,700,13130,138,0008,331,00092,766,208
2Sep 14, 2026 21:464,22948,759,02730,304,0008,181,00092,778,496
3Sep 14, 2026 21:464,23148,800,22529,843,0008,668,00092,749,824
4Sep 14, 2026 21:464,23448,824,89130,362,0008,169,00092,758,016
5Sep 14, 2026 21:464,24648,918,18630,346,0008,294,00092,770,304
6Sep 14, 2026 21:464,24948,851,82030,272,0008,395,00092,749,824
7Sep 14, 2026 21:464,25148,911,54330,359,0008,334,00092,790,784
8Sep 14, 2026 21:464,25151,907,93330,415,0008,275,00092,737,536
9Sep 14, 2026 21:464,25848,966,73330,400,0008,350,00092,704,768