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 listDec 24, 2025 01:15Josu San MartinJosu San MartinError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 5, 2026 06:12Tomislav Tunkovic32.22CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 5, 2026 06:290336,967,289308,667,00018,168,000100,687,872diff: map[string]any{ - "height": s"181", + "height": s"181.0", "id": s"641576", "married": bool(false), }
2Sep 5, 2026 06:290337,534,546308,743,00018,088,000100,687,872invalid character '0' after object key:value pair
3Sep 5, 2026 06:290336,994,742308,875,00018,042,000100,687,872diff: map[string]any{ "age": s"27", - "height": s"183.5", + "height": s"183.4999999999999999999999999", "id": s"217937", "married": bool(true), "phones": []any{map[string]any{"code": string("+9"), "number": s"1052034679"}}, ...
4Dec 24, 2025 01:1530,838307,823,885261,655,00018,975,00094,601,216
5Dec 24, 2025 01:1530,962305,229,158261,772,00019,982,00094,617,600
6Dec 24, 2025 01:1530,995304,706,690264,052,00018,003,00094,617,600
7Dec 24, 2025 01:1530,997305,278,864264,069,00018,004,00094,572,544
8Dec 24, 2025 01:1531,034312,678,011263,385,00019,027,00094,785,536
9Dec 24, 2025 01:1531,260308,801,187262,508,00021,958,00094,584,832
10Dec 24, 2025 01:1531,359318,562,859267,408,00017,960,00094,785,536
11Dec 24, 2025 01:1531,420313,630,389264,927,00020,994,00094,789,632
12Dec 24, 2025 01:1532,640321,975,626268,025,00029,002,00094,560,256