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 1, 2026 22:49A_ShamanA_ShamanScore: 67,236Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 1, 2026 22:5567,119620,670,882498,181,000112,608,000169,893,888
2Jul 1, 2026 22:5567,132620,387,949498,146,000112,757,000169,893,888
3Jul 1, 2026 22:5567,151621,106,809498,645,000112,434,000171,991,040
4Jul 1, 2026 22:5567,227621,688,283498,719,000113,052,000171,991,040
5Jul 1, 2026 22:5567,236621,442,119498,712,000113,143,000171,991,040
6Jul 1, 2026 22:5567,289622,006,611499,024,000113,308,000169,893,888
7Jul 1, 2026 22:5567,367622,903,621500,209,000112,834,000171,991,040
8Jul 1, 2026 22:5567,367622,548,744499,036,000114,012,000169,893,888
9Jul 1, 2026 22:5567,396623,239,480500,491,000112,815,000171,991,040