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 listMay 21, 2026 16:19M-RochatM-RochatScore: 6,128Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 21, 2026 16:246,10264,817,62939,084,00016,452,00094,392,320
2May 21, 2026 16:246,10764,828,72238,986,00016,594,00094,392,320
3May 21, 2026 16:246,12568,041,43538,492,00017,250,00094,392,320
4May 21, 2026 16:246,12568,991,46139,114,00016,632,00094,392,320
5May 21, 2026 16:246,12865,699,66539,135,00016,632,00094,392,320
6May 21, 2026 16:246,13366,150,72539,110,00016,709,00094,392,320
7May 21, 2026 16:246,13667,847,95439,128,00016,717,00094,392,320
8May 21, 2026 16:246,15565,322,66838,596,00017,422,00094,392,320
9May 21, 2026 16:246,20067,516,70839,861,00016,565,00094,392,320