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 21, 2026 17:40Dominique GarmierDominique GarmierScore: 7,371Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 21, 2026 18:257,34495,074,34944,886,00021,944,00094,625,792
2Mar 21, 2026 17:407,34889,822,26345,909,00020,958,00094,625,792
3Mar 21, 2026 18:257,34989,557,20944,915,00021,958,00094,621,696
4Mar 21, 2026 17:407,37185,143,76343,050,00024,028,00094,617,600
5Mar 21, 2026 18:257,37491,882,52845,067,00022,032,00094,810,112
6Mar 21, 2026 17:407,39491,764,54245,192,00022,093,00094,633,984