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 listJun 8, 2026 21:05Victor MerckléVictor MerckléScore: 2,781Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 8, 2026 21:112,75632,857,65916,559,0008,523,00092,794,880
2Jun 8, 2026 21:112,76432,876,01816,587,0008,570,00092,745,728
3Jun 8, 2026 21:112,76833,046,29616,648,0008,546,00092,721,152
4Jun 8, 2026 21:112,77232,981,97516,664,0008,565,00092,696,576
5Jun 8, 2026 21:112,78133,093,03116,706,0008,608,00092,704,768
6Jun 8, 2026 21:112,78333,125,28916,699,0008,634,00092,704,768
7Jun 8, 2026 21:112,78733,054,28316,696,0008,671,00092,733,440
8Jun 8, 2026 21:112,79033,159,30016,730,0008,660,00092,762,112
9Jun 8, 2026 21:112,80033,228,24716,784,0008,702,00092,721,152