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 listJul 30, 2026 03:11Andrew TsibinAndrew TsibinScore: 5,369Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 30, 2026 03:164,89054,703,19327,898,00016,606,00094,392,320
2Jul 30, 2026 03:164,89154,566,88427,953,00016,563,00094,392,320
3Jul 30, 2026 03:164,92156,654,49727,377,00017,406,00094,392,320
4Jul 30, 2026 03:164,92256,586,63527,340,00017,454,00094,392,320
5Jul 30, 2026 03:165,36958,916,64627,412,00021,447,00092,876,800
6Jul 30, 2026 03:165,46559,964,92527,252,00022,484,00092,930,048
7Jul 30, 2026 03:165,52960,481,15227,510,00022,809,00092,942,336
8Jul 30, 2026 03:165,65661,913,31727,507,00023,969,00093,003,776
9Jul 30, 2026 03:165,67462,460,27927,671,00023,968,00092,905,472