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 listSep 14, 2026 21:53Andrew EpsteinAndrew EpsteinScore: 3,967Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 14, 2026 22:073,94146,359,37127,253,0008,614,00092,770,304
2Sep 14, 2026 22:073,95147,164,39427,199,0008,760,00092,766,208
3Sep 14, 2026 22:073,96046,290,39727,451,0008,590,00092,721,152
4Sep 14, 2026 22:073,96546,367,70527,392,0008,695,00092,753,920
5Sep 14, 2026 22:073,96747,190,31527,454,0008,653,00092,770,304
6Sep 14, 2026 22:073,97246,406,21427,550,0008,599,00092,753,920
7Sep 14, 2026 22:073,98554,702,31327,658,0008,614,00092,725,248
8Sep 14, 2026 22:074,00360,223,36827,798,0008,636,00092,729,344
9Sep 14, 2026 22:074,01256,118,50327,786,0008,728,00092,725,248