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 21:17A_ShamanA_ShamanError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Sep 18, 2026 01:30Andrew Epstein10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 18, 2026 01:350400,379,759338,682,00051,223,000215,564,288diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
2Sep 18, 2026 01:350400,517,197339,742,00050,320,000215,560,192diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
3Sep 18, 2026 01:350399,998,966339,376,00050,123,000215,707,648diff: map[string]any{ + "age": s"0", "height": s"169.1", "id": s"4294967295", "married": bool(true), }
4Jul 1, 2026 21:2337,096347,517,670307,375,00030,200,000169,893,888
5Jul 1, 2026 21:2337,124347,801,733307,634,00030,196,000169,893,888
6Jul 1, 2026 21:2337,154347,718,962307,616,00030,492,000171,991,040
7Jul 1, 2026 21:2337,157347,616,119307,482,00030,649,000169,893,888
8Jul 1, 2026 21:2337,157347,655,341307,848,00030,283,000171,991,040
9Jul 1, 2026 21:2337,200348,003,532307,999,00030,524,000171,991,040
10Jul 1, 2026 21:2337,229348,251,694308,125,00030,663,000171,991,040
11Jul 1, 2026 21:2337,353349,847,319309,421,00030,498,000169,893,888
12Jul 1, 2026 21:2337,417350,495,909310,010,00030,487,000171,991,040