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 17, 2026 00:53M-RochatM-RochatScore: 8,997Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 17, 2026 00:588,96490,478,93965,354,00016,222,00094,392,320
2May 17, 2026 00:588,96692,320,40365,380,00016,216,00094,392,320
3May 17, 2026 00:588,96790,470,82465,400,00016,201,00094,392,320
4May 17, 2026 00:588,97390,343,32265,358,00016,300,00094,392,320
5May 17, 2026 00:588,99792,253,25164,743,00017,137,00094,392,320
6May 17, 2026 00:589,00190,674,65865,408,00016,510,00094,392,320
7May 17, 2026 00:589,00590,881,82665,414,00016,534,00094,392,320
8May 17, 2026 00:589,00790,734,84864,808,00017,164,00094,392,320
9May 17, 2026 00:589,01690,912,86164,927,00017,122,00094,392,320