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 21, 2026 10:10limanjun99limanjun99Score: 3,853Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 21, 2026 10:123,82062,578,85325,826,0008,939,00092,876,800
2Apr 21, 2026 10:123,82664,564,20223,877,00010,943,00093,122,560
3Apr 21, 2026 10:123,83159,606,48525,904,0008,966,00092,901,376
4Apr 21, 2026 10:123,84757,687,82627,007,0008,002,00092,872,704
5Apr 21, 2026 10:123,85363,423,66128,056,0007,014,00092,889,088
6Apr 21, 2026 10:123,85459,580,95725,052,00010,020,00092,905,472
7Apr 21, 2026 10:123,86058,533,71624,087,00011,039,00093,126,656
8Apr 21, 2026 10:123,86761,648,94427,152,0008,045,00093,163,520
9Apr 21, 2026 10:124,14853,555,31124,836,00012,914,00092,880,896