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 listApr 22, 2026 20:58Dominique GarmierDominique GarmierScore: 5,449Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2026 21:005,43370,578,16026,238,00023,211,00094,617,600
2Apr 22, 2026 21:005,43669,942,84322,757,00026,715,00094,593,024
3Apr 22, 2026 21:005,44268,516,68525,753,00023,772,00094,593,024
4Apr 22, 2026 21:005,44763,343,60125,778,00023,795,00094,605,312
5Apr 22, 2026 21:005,44968,551,92224,796,00024,796,00094,609,408
6Apr 22, 2026 21:005,46867,278,30125,391,00024,376,00094,613,504
7Apr 22, 2026 21:005,46870,231,47224,881,00024,881,00094,597,120
8Apr 22, 2026 21:005,47966,182,72223,933,00025,928,00094,593,024
9Apr 22, 2026 21:005,50368,692,87224,038,00026,041,00094,593,024