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 20:56Andrew EpsteinAndrew EpsteinScore: 3,378Success
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:173,35940,924,62422,136,0008,437,00092,717,056
2Sep 14, 2026 21:173,36040,877,36422,168,0008,415,00092,782,592
3Sep 14, 2026 21:173,37041,074,36222,046,0008,624,00092,782,592
4Sep 14, 2026 21:173,37141,690,51322,068,0008,609,00092,745,728
5Sep 14, 2026 21:173,37841,081,05622,207,0008,535,00092,729,344
6Sep 14, 2026 21:173,37941,111,57522,090,0008,665,00092,766,208
7Sep 14, 2026 21:173,38441,106,01722,261,0008,538,00092,741,632
8Sep 14, 2026 21:173,38741,110,41722,308,0008,515,00092,823,552
9Sep 14, 2026 21:173,40041,271,55322,367,0008,578,00092,778,496