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 17, 2026 20:31Andrew EpsteinAndrew EpsteinScore: 3,094Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 17, 2026 20:433,07936,679,01919,486,0008,535,00092,753,920
2Sep 17, 2026 20:433,08736,729,99119,814,0008,285,00092,770,304
3Sep 17, 2026 20:433,09336,806,20219,810,0008,340,00092,741,632
4Sep 17, 2026 20:433,09336,867,18919,827,0008,326,00092,782,592
5Sep 17, 2026 20:433,09436,884,85819,836,0008,323,00092,749,824
6Sep 17, 2026 20:433,11136,993,93219,914,0008,404,00092,741,632
7Sep 17, 2026 20:433,11537,018,12819,915,0008,433,00092,700,672
8Sep 17, 2026 20:434,03845,451,19819,814,00016,940,00092,712,960
9Sep 17, 2026 20:435,73961,160,05821,070,00031,157,00092,733,440