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 listMar 17, 2026 09:41Dominique GarmierDominique GarmierScore: 7,816Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 17, 2026 09:417,772101,582,88150,801,00019,922,00094,797,824
2Mar 17, 2026 09:417,77699,388,77651,825,00018,936,00094,711,808
3Mar 17, 2026 09:417,78298,325,02053,858,00016,955,00094,543,872
4Mar 17, 2026 09:417,78592,156,06750,885,00019,955,00094,564,352
5Mar 17, 2026 09:417,79897,494,72950,975,00019,990,00094,564,352
6Mar 17, 2026 09:417,79899,265,30452,975,00017,991,00094,564,352
7Mar 17, 2026 09:417,79993,065,50950,978,00019,991,00094,793,728
8Mar 17, 2026 09:417,79996,756,87850,980,00019,992,00094,564,352
9Mar 17, 2026 09:417,81397,202,37452,073,00019,026,00094,564,352
10Mar 17, 2026 09:417,81692,854,70354,094,00017,029,00094,650,368
11Mar 17, 2026 09:417,81693,839,21555,099,00016,029,00094,556,160
12Mar 17, 2026 09:417,81995,722,09752,111,00019,040,00094,564,352
13Mar 17, 2026 09:417,82293,396,60353,135,00018,045,00094,797,824
14Mar 17, 2026 09:417,83399,998,28853,208,00018,070,00094,543,872
15Mar 17, 2026 09:417,848100,655,09957,333,00014,081,00094,568,448
16Mar 17, 2026 09:417,84893,558,09051,301,00020,118,00094,793,728
17Mar 17, 2026 09:417,84997,994,61053,321,00018,109,00094,793,728
18Mar 17, 2026 09:417,85594,702,11152,353,00019,129,00094,564,352