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 listMar 17, 2026 09:44Dominique GarmierDominique GarmierScore: 9,900Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 09:419,887120,989,00078,974,00010,996,00094,564,352
2Mar 17, 2026 09:449,888120,844,94081,986,0007,998,00094,543,872
3Mar 17, 2026 09:399,894113,120,72578,029,00012,004,00094,543,872
4Mar 17, 2026 09:419,896116,742,72481,047,0009,005,00094,564,352
5Mar 17, 2026 09:399,900116,765,05375,075,00015,015,00094,543,872
6Mar 17, 2026 09:449,902112,975,06977,090,00013,015,00094,556,160
7Mar 17, 2026 09:419,908111,669,97477,143,00013,024,00094,543,872
8Mar 17, 2026 09:449,909115,022,54081,155,0009,017,00094,564,352
9Mar 17, 2026 09:399,928115,968,81980,307,00010,038,00094,793,728