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 28, 2026 20:04Shikhar SoniShikhar SoniError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 4, 2026 10:53Tomislav Tunkovic88.55CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2026 10:55086,918,85158,819,00018,222,00077,615,104invalid character '1' after object key:value pair
2Sep 4, 2026 10:55087,777,12059,389,00018,542,00077,615,104diff: map[string]any{ "age": s"27", "height": s"173.9", "id": s"852994", - "married": bool(true), + "married": bool(false), - "phones": []any{ - map[string]any{"code": string("+0"), "number": s"1921558170"}, - map[string]any...
3Sep 4, 2026 10:55087,679,36358,783,00018,378,00077,615,104invalid character '0' after object key:value pair
4Jun 28, 2026 20:105,26957,264,74926,625,00021,324,00094,392,320
5Jun 28, 2026 20:105,27457,482,59926,604,00021,391,00094,392,320
6Jun 28, 2026 20:105,28557,460,46226,682,00021,420,00094,392,320
7Jun 28, 2026 20:105,28657,373,53026,595,00021,516,00094,392,320
8Jun 28, 2026 20:105,30857,554,43026,681,00021,625,00094,392,320
9Jun 28, 2026 20:105,31758,021,61926,727,00021,660,00094,392,320
10Jun 28, 2026 20:105,38358,408,06026,401,00022,586,00094,392,320
11Jun 28, 2026 20:105,46659,443,45226,079,00023,665,00094,392,320
12Jun 28, 2026 20:105,50359,827,57925,952,00024,133,00094,392,320