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 02:14Andrew EpsteinAndrew EpsteinScore: 3,592Success
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 02:233,56542,740,35923,918,0008,530,00092,696,576
2Sep 14, 2026 02:233,57842,940,24123,970,0008,594,00092,762,112
3Sep 14, 2026 02:233,58542,920,52724,028,0008,599,00092,790,784
4Sep 14, 2026 02:233,59243,039,27424,063,0008,628,00092,725,248
5Sep 14, 2026 02:233,59243,693,61324,041,0008,649,00092,770,304
6Sep 14, 2026 02:233,60043,166,52824,099,0008,662,00092,778,496
7Sep 14, 2026 02:233,60643,864,56624,077,0008,744,00092,753,920
8Sep 14, 2026 02:233,60843,243,15424,174,0008,664,00092,753,920
9Sep 14, 2026 02:233,61043,906,75424,104,0008,750,00092,790,784