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 28, 2026 10:04TudyMTudyMScore: 17,273Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 28, 2026 10:0617,201175,496,173132,607,00023,929,00094,625,792
2Apr 28, 2026 10:0617,211170,561,169133,677,00022,944,00094,576,640
3Apr 28, 2026 10:0617,268174,405,380133,121,00024,021,00094,584,832
4Apr 28, 2026 10:0617,270175,848,582137,265,00019,893,00094,629,888
5Apr 28, 2026 10:0617,273173,432,002134,163,00023,027,00094,629,888
6Apr 28, 2026 10:0617,297177,658,846138,362,00019,049,00094,638,080
7Apr 28, 2026 10:0617,318174,018,378132,659,00024,935,00094,646,272
8Apr 28, 2026 10:0617,320178,599,404136,671,00020,949,00094,642,176
9Apr 28, 2026 10:0617,376173,317,189132,108,00026,021,00094,629,888