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 listJun 5, 2026 17:06Victor MerckléVictor MerckléScore: 2,761Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 5, 2026 17:122,74634,042,26816,330,0008,665,00092,717,056
2Jun 5, 2026 17:122,74634,199,24216,303,0008,689,00092,782,592
3Jun 5, 2026 17:122,75634,116,75616,630,0008,451,00092,741,632
4Jun 5, 2026 17:122,75934,267,14516,371,0008,738,00092,798,976
5Jun 5, 2026 17:122,76134,222,43916,408,0008,725,00092,778,496
6Jun 5, 2026 17:122,76334,146,01016,694,0008,455,00092,737,536
7Jun 5, 2026 17:122,76734,293,33716,379,0008,805,00092,794,880
8Jun 5, 2026 17:122,76934,233,77816,660,0008,543,00092,749,824
9Jun 5, 2026 17:122,78234,336,93016,719,0008,601,00092,770,304