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 listJul 1, 2026 23:00A_ShamanA_ShamanScore: 49,296Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 1, 2026 23:0649,089456,283,382396,334,00050,380,000169,897,984
2Jul 1, 2026 23:0649,271458,327,784397,247,00051,121,000171,991,040
3Jul 1, 2026 23:0649,275459,913,028397,341,00051,067,000169,897,984
4Jul 1, 2026 23:0649,289458,135,221397,480,00051,050,000171,995,136
5Jul 1, 2026 23:0649,296458,162,512397,317,00051,280,000169,897,984
6Jul 1, 2026 23:0649,301458,159,443397,309,00051,336,000171,995,136
7Jul 1, 2026 23:0649,313458,732,937397,983,00050,767,000169,893,888
8Jul 1, 2026 23:0649,315458,501,625397,662,00051,111,000171,995,136
9Jul 1, 2026 23:0650,229466,692,331403,229,00053,863,000169,897,984