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 listJan 20, 2025 16:16BlankBot-0BlankBot-0Score: 1,385,347Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 20, 2025 16:161,365,26112,458,362,25712,111,126,000312,745,000170,196,992
2Jan 20, 2025 16:161,377,07412,567,632,10512,246,615,000284,758,000172,175,360
3Jan 20, 2025 16:161,378,74912,582,359,68612,270,847,000275,771,000170,147,840
4Jan 20, 2025 16:161,379,69312,591,790,25312,265,432,000289,773,000172,224,512
5Jan 20, 2025 16:161,385,34712,643,340,89612,307,904,000298,754,000172,331,008
6Jan 20, 2025 16:161,386,35612,655,874,14012,283,106,000332,732,000170,123,264
7Jan 20, 2025 16:161,389,74912,678,633,73812,337,996,000308,724,000170,246,144
8Jan 20, 2025 16:161,395,13312,739,950,15812,395,004,000300,708,000172,294,144
9Jan 20, 2025 16:161,401,77812,795,270,89112,455,410,000300,768,000172,384,256