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 listApr 24, 2026 02:38olliecrowolliecrowScore: 6,330Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 24, 2026 02:426,27876,642,31941,098,00016,038,00094,830,592
2Apr 24, 2026 02:426,29965,644,48340,228,00017,097,00094,654,464
3Apr 24, 2026 02:426,31565,883,46440,330,00017,140,00094,654,464
4Apr 24, 2026 02:426,31973,967,47839,660,00017,847,00094,838,784
5Apr 24, 2026 02:426,33065,982,22938,402,00019,201,00094,650,368
6Apr 24, 2026 02:426,34866,206,62541,836,00015,937,00094,633,984
7Apr 24, 2026 02:426,35866,203,99438,905,00018,953,00094,588,928
8Apr 24, 2026 02:426,38266,248,54142,061,00016,023,00094,654,464
9Apr 24, 2026 02:426,38966,677,63243,104,00015,036,00094,629,888