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 listMar 10, 2026 04:22Josu San MartinJosu San MartinScore: 4,108Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 10, 2026 04:224,09558,879,40221,149,00016,113,00094,679,040
2Mar 10, 2026 04:224,09762,901,37320,154,00017,131,00094,552,064
3Mar 10, 2026 04:224,10057,944,55718,151,00019,159,00094,674,944
4Mar 10, 2026 04:224,10559,496,58517,161,00020,190,00094,679,040
5Mar 10, 2026 04:224,10859,967,41418,187,00019,197,00094,674,944
6Mar 10, 2026 04:224,10965,449,51318,192,00019,202,00094,670,848
7Mar 10, 2026 04:224,11361,510,24018,210,00019,222,00094,552,064
8Mar 10, 2026 04:224,12167,337,66521,283,00016,215,00094,552,064
9Mar 10, 2026 04:224,17561,337,77219,994,00017,995,00094,674,944