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 listApr 8, 2026 12:16olliecrowolliecrowScore: 7,232Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 8, 2026 12:137,18592,658,41248,284,00017,100,00094,679,040
2Apr 8, 2026 12:117,19190,418,59147,314,00018,120,00094,679,040
3Apr 8, 2026 12:197,19690,130,99849,365,00016,119,00094,674,944
4Apr 8, 2026 12:117,19794,043,26049,615,00015,877,00094,670,848
5Apr 8, 2026 12:117,21890,326,93049,762,00015,924,00094,552,064
6Apr 8, 2026 12:197,22889,971,18648,836,00016,943,00094,683,136
7Apr 8, 2026 12:137,23296,806,09248,858,00016,950,00094,662,656
8Apr 8, 2026 12:137,23692,284,46847,890,00017,958,00094,547,968
9Apr 8, 2026 12:197,23791,588,83048,891,00016,962,00094,687,232
10Apr 8, 2026 12:167,24893,086,39446,970,00018,988,00094,674,944
11Apr 8, 2026 12:167,25391,820,92848,003,00018,001,00094,552,064
12Apr 8, 2026 12:167,25787,668,56748,029,00018,010,00094,552,064