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 11, 2026 02:44Victor MerckléVictor MerckléScore: 2,857Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 02:502,84035,662,94716,963,0008,885,00092,745,728
2Jun 11, 2026 02:502,84435,484,22417,020,0008,869,00092,762,112
3Jun 11, 2026 02:502,84633,905,50516,952,0008,953,00092,749,824
4Jun 11, 2026 02:502,85635,783,81617,062,0008,935,00092,798,976
5Jun 11, 2026 02:502,85733,565,55817,057,0008,946,00092,807,168
6Jun 11, 2026 02:502,85835,589,09117,105,0008,906,00092,794,880
7Jun 11, 2026 02:502,87436,440,46117,268,0008,886,00092,745,728
8Jun 11, 2026 02:502,89333,830,19817,199,0009,129,00092,794,880
9Jun 11, 2026 02:502,90233,926,82917,228,0009,185,00092,774,400