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 listAug 9, 2022 16:35Eugene ZhydzetskiEugene ZhydzetskiError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 9, 2026 02:27C#_user10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 9, 2026 03:140219,759,955156,733,00054,029,000100,749,312invalid character ',' looking for beginning of valuestderr
2Sep 9, 2026 03:140221,430,664156,915,00055,807,000100,761,600invalid character ',' looking for beginning of valuestderr
3Sep 9, 2026 03:140220,336,305157,011,00054,806,000100,765,696invalid character ',' looking for beginning of valuestderr
4Aug 9, 2022 16:3520,519262,757,045186,720,273092,651,520
5Aug 9, 2022 16:3520,544248,409,498186,950,781092,672,000
6Aug 9, 2022 16:3520,577259,187,269187,248,712092,655,616