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 5, 2026 05:06Andrew EpsteinAndrew EpsteinScore: 2,372Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 5, 2026 05:472,34330,514,09312,893,0008,436,00092,741,632
2Nov 5, 2026 05:472,34830,529,63412,934,0008,433,00092,729,344
3Nov 5, 2026 05:472,34930,592,90012,987,0008,390,00092,753,920
4Nov 5, 2026 05:472,36630,690,90913,073,0008,464,00092,762,112
5Nov 5, 2026 05:472,37230,792,58613,070,0008,516,00092,790,784
6Nov 5, 2026 05:472,37230,772,55613,167,0008,419,00092,676,096
7Nov 5, 2026 05:472,38332,291,61213,270,0008,424,00092,733,440
8Nov 5, 2026 05:472,39231,003,25813,226,0008,549,00092,729,344
9Nov 5, 2026 05:472,40131,402,83513,311,0008,540,00092,708,864