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 3, 2026 15:34A_ShamanA_ShamanScore: 31,872Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 3, 2026 15:4031,807299,339,533238,174,00051,278,000169,893,888
2Jul 3, 2026 15:4031,820299,524,231238,200,00051,364,000171,991,040
3Jul 3, 2026 15:4031,856300,864,387238,492,00051,402,000171,991,040
4Jul 3, 2026 15:4031,868300,008,227238,493,00051,510,000171,991,040
5Jul 3, 2026 15:4031,872300,037,281238,323,00051,720,000169,893,888
6Jul 3, 2026 15:4031,884300,149,664238,491,00051,660,000171,991,040
7Jul 3, 2026 15:4031,895300,293,976238,529,00051,724,000169,893,888
8Jul 3, 2026 15:4031,915300,391,236238,213,00052,221,000171,991,040
9Jul 3, 2026 15:4032,322304,110,704240,468,00053,670,000171,991,040