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 10, 2026 00:47Victor MerckléVictor MerckléScore: 3,060Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 10, 2026 00:533,03236,526,37618,930,0008,669,00092,655,616
2Jun 10, 2026 00:533,03336,587,64219,128,0008,481,00092,807,168
3Jun 10, 2026 00:533,03936,694,51019,045,0008,610,00092,704,768
4Jun 10, 2026 00:533,04236,696,09419,167,0008,517,00092,692,480
5Jun 10, 2026 00:533,06036,777,70519,046,0008,806,00092,717,056
6Jun 10, 2026 00:533,06036,879,65719,243,0008,607,00092,729,344
7Jun 10, 2026 00:533,07346,516,68319,425,0008,546,00092,762,112
8Jun 10, 2026 00:533,09047,316,00519,476,0008,646,00092,721,152
9Jun 10, 2026 00:533,10047,400,48619,564,0008,652,00092,778,496