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 listOct 14, 2026 11:00Karthik ReddyKarthik ReddyScore: 3,594Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 14, 2026 11:053,45440,352,01722,979,0008,454,00092,921,856
2Oct 14, 2026 11:053,57241,416,67123,958,0008,554,00092,868,608
3Oct 14, 2026 11:053,58241,690,62223,958,0008,642,00092,856,320
4Oct 14, 2026 11:053,58942,733,44424,066,0008,595,00092,884,992
5Oct 14, 2026 11:053,59441,702,74524,188,0008,519,00092,876,800
6Oct 14, 2026 11:053,59841,824,10124,332,0008,414,00092,901,376
7Oct 14, 2026 11:053,61841,975,52324,524,0008,401,00092,839,936
8Oct 14, 2026 11:053,64542,139,72624,629,0008,544,00092,893,184
9Oct 14, 2026 11:053,67242,412,17124,852,0008,567,00092,872,704