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:23Andrew EpsteinAndrew EpsteinScore: 4,257Success
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:414,24047,231,95030,505,0008,084,00092,712,960
2Sep 14, 2026 21:414,24347,187,32630,771,0007,847,00092,770,304
3Sep 14, 2026 21:414,24447,295,04030,529,0008,094,00092,737,536
4Sep 14, 2026 21:414,25147,305,82230,548,0008,144,00092,762,112
5Sep 14, 2026 21:414,25747,342,10930,386,0008,360,00092,778,496
6Sep 14, 2026 21:414,26047,434,91230,163,0008,610,00092,741,632
7Sep 14, 2026 21:414,26047,477,57230,237,0008,532,00092,803,072
8Sep 14, 2026 21:414,26047,356,99330,423,0008,351,00092,798,976
9Sep 14, 2026 21:414,26247,427,51130,419,0008,367,00092,782,592