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 listMar 30, 2026 17:23Dominique GarmierDominique GarmierScore: 6,624Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 30, 2026 17:236,58885,086,79434,972,00024,980,00094,543,872
2Mar 30, 2026 17:236,59281,500,72937,992,00021,995,00094,543,872
3Mar 30, 2026 17:236,60285,793,55939,048,00021,026,00094,543,872
4Mar 30, 2026 17:236,62186,753,32037,157,00023,097,00094,797,824
5Mar 30, 2026 17:236,62490,255,53536,168,00024,112,00094,552,064
6Mar 30, 2026 17:236,63483,196,65037,226,00023,140,00094,699,520
7Mar 30, 2026 17:236,63487,801,02139,243,00021,130,00094,760,960
8Mar 30, 2026 17:236,77187,288,02939,750,00021,862,00094,658,560
9Mar 30, 2026 17:236,79990,172,32037,919,00023,949,00094,560,256