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 21:47A_ShamanA_ShamanScore: 45,161Success
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 21:5345,103420,318,344362,953,00047,491,000169,893,888
2Jul 1, 2026 21:5345,122420,535,455363,183,00047,428,000169,893,888
3Jul 1, 2026 21:5345,127420,120,246363,641,00047,020,000171,991,040
4Jul 1, 2026 21:5345,130420,617,665363,338,00047,354,000171,991,040
5Jul 1, 2026 21:5345,161420,529,950363,680,00047,294,000169,893,888
6Jul 1, 2026 21:5345,193421,135,213363,915,00047,345,000169,893,888
7Jul 1, 2026 21:5345,223421,026,115364,089,00047,444,000171,991,040
8Jul 1, 2026 21:5345,235421,164,958364,071,00047,574,000171,991,040
9Jul 1, 2026 21:5346,108429,459,406371,109,00048,474,000171,991,040