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 listMay 14, 2026 17:47Josu San MartinJosu San MartinScore: 33,111Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 14, 2026 17:5333,049309,790,095271,841,00028,911,000169,893,888
2May 14, 2026 17:5333,074309,794,985271,865,00029,110,000169,893,888
3May 14, 2026 17:5333,087310,137,113271,912,00029,182,000169,893,888
4May 14, 2026 17:5333,090308,819,259272,254,00028,868,000171,991,040
5May 14, 2026 17:5333,111308,484,556272,247,00029,066,000169,893,888
6May 14, 2026 17:5333,124309,002,488272,213,00029,221,000171,991,040
7May 14, 2026 17:5333,125308,845,489272,451,00028,993,000171,991,040
8May 14, 2026 17:5333,130309,146,801272,198,00029,287,000171,991,040
9May 14, 2026 17:5333,143309,744,576272,365,00029,240,000171,991,040