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 11, 2026 18:13Victor MerckléVictor MerckléScore: 2,704Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 11, 2026 18:192,69633,566,58315,812,0008,730,00092,696,576
2Jun 11, 2026 18:192,69733,520,82415,684,0008,860,00092,741,632
3Jun 11, 2026 18:192,69933,581,46815,818,0008,746,00092,782,592
4Jun 11, 2026 18:192,70333,683,10615,863,0008,743,00092,770,304
5Jun 11, 2026 18:192,70433,576,62815,840,0008,773,00092,749,824
6Jun 11, 2026 18:192,70633,650,99615,845,0008,787,00092,692,480
7Jun 11, 2026 18:192,71833,682,31915,911,0008,828,00092,729,344
8Jun 11, 2026 18:192,71934,975,52215,899,0008,845,00092,737,536
9Jun 11, 2026 18:192,73533,883,74115,999,0008,895,00092,753,920