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 23, 2026 22:51Charles CabergsCharles CabergsScore: 4,730Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2026 22:534,68058,768,04025,751,00016,837,00094,793,728
2Apr 23, 2026 22:534,69558,322,74627,824,00014,906,00094,797,824
3Apr 23, 2026 22:534,72358,686,72926,989,00015,993,00094,785,536
4Apr 23, 2026 22:534,72760,063,52524,011,00019,008,00094,781,440
5Apr 23, 2026 22:534,73059,799,55724,024,00019,019,00094,789,632
6Apr 23, 2026 22:534,74857,370,44827,132,00016,078,00094,789,632
7Apr 23, 2026 22:534,74857,844,20826,126,00017,082,00094,801,920
8Apr 23, 2026 22:534,76361,961,30126,209,00017,136,00094,789,632
9Apr 23, 2026 22:534,76859,985,70626,239,00017,156,00094,609,408