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 5, 2026 02:39olliecrowolliecrowScore: 4,328Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2026 02:444,28656,037,53722,420,00016,591,00094,666,752
2May 5, 2026 02:444,29556,077,00722,447,00016,645,00094,670,848
3May 5, 2026 02:444,30255,824,09722,444,00016,712,00094,650,368
4May 5, 2026 02:444,32859,390,91422,488,00016,903,00094,662,656
5May 5, 2026 02:444,32859,291,95922,477,00016,910,00094,666,752
6May 5, 2026 02:444,33660,445,59322,529,00016,930,00094,662,656
7May 5, 2026 02:444,33853,828,98322,565,00016,914,00094,654,464
8May 5, 2026 02:444,34156,411,18122,059,00017,448,00094,666,752
9May 5, 2026 02:444,34657,785,71121,985,00017,569,00094,658,560