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 09:59TudyMTudyMScore: 16,551Success
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:0316,513168,194,058129,232,00021,037,00094,638,080
2Apr 28, 2026 10:0316,515167,753,214129,388,00020,901,00094,588,928
3Apr 28, 2026 10:0316,522171,303,532128,446,00021,905,00094,617,600
4Apr 28, 2026 10:0316,536172,562,311128,408,00022,070,00094,633,984
5Apr 28, 2026 10:0316,551167,626,631129,535,00021,087,00094,584,832
6Apr 28, 2026 10:0316,552164,418,763128,683,00021,946,00094,597,120
7Apr 28, 2026 10:0316,559167,451,403128,734,00021,954,00094,629,888
8Apr 28, 2026 10:0316,574169,158,325126,020,00024,807,00094,699,520
9Apr 28, 2026 10:0316,587172,024,787129,955,00020,992,00094,629,888