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 listNov 3, 2026 01:54Andrew EpsteinAndrew EpsteinScore: 5,285Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 3, 2026 02:165,26658,783,17039,580,0008,341,00092,749,824
2Nov 3, 2026 02:165,27759,403,44739,634,0008,394,00092,708,864
3Nov 3, 2026 02:165,28159,594,64539,656,0008,404,00092,749,824
4Nov 3, 2026 02:165,28559,477,15639,644,0008,452,00092,745,728
5Nov 3, 2026 02:165,28559,530,89039,684,0008,410,00092,712,960
6Nov 3, 2026 02:165,29259,499,21639,751,0008,407,00092,696,576
7Nov 3, 2026 02:165,29659,565,62539,697,0008,498,00092,758,016
8Nov 3, 2026 02:165,29761,147,19139,764,0008,439,00092,729,344
9Nov 3, 2026 02:165,30259,608,79439,715,0008,537,00092,758,016