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 23:47Andrew EpsteinAndrew EpsteinScore: 2,917Success
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 23:522,89336,409,51917,896,0008,433,00092,733,440
2Sep 14, 2026 23:522,89936,532,05117,673,0008,713,00092,737,536
3Sep 14, 2026 23:522,90436,488,89017,713,0008,715,00092,737,536
4Sep 14, 2026 23:522,91536,684,86618,022,0008,513,00092,753,920
5Sep 14, 2026 23:522,91737,403,50818,053,0008,494,00092,688,384
6Sep 14, 2026 23:522,92336,893,35318,109,0008,498,00092,708,864
7Sep 14, 2026 23:522,92536,740,93718,027,0008,593,00092,741,632
8Sep 14, 2026 23:522,93036,812,34818,107,0008,564,00092,733,440
9Sep 14, 2026 23:522,93636,896,64518,156,0008,565,00092,704,768