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 listApr 29, 2026 12:48TudyMTudyMScore: 15,213Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 29, 2026 12:4915,165155,996,828114,004,00024,000,00094,646,272
2Apr 29, 2026 12:4915,174152,889,013117,076,00021,013,00094,638,080
3Apr 29, 2026 12:4915,188157,587,067115,177,00023,035,00094,633,984
4Apr 29, 2026 12:4915,208157,387,454115,498,00022,900,00094,818,304
5Apr 29, 2026 12:4915,213158,133,375116,533,00021,912,00094,588,928
6Apr 29, 2026 12:4915,216159,855,372115,558,00022,912,00094,650,368
7Apr 29, 2026 12:4915,287157,436,297117,098,00022,018,00094,646,272
8Apr 29, 2026 12:4915,453158,835,568115,690,00024,933,00094,584,832
9Apr 29, 2026 12:4915,528165,441,022115,433,00025,872,00094,646,272