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 25, 2026 22:35Charles CabergsCharles CabergsError
Source Code

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

Challenge History
DateChallengerCostTypeStatus
Jul 6, 2026 09:38Victor Mercklé10.00CustomSolution Broken
Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 6, 2026 09:40011,492,31502,090,0002,121,728invalid character '<' after object key:value pair
2Jul 6, 2026 09:40012,270,17402,480,0002,121,728invalid character '<' after object key:value pair
3Jul 6, 2026 09:40011,460,97202,171,0002,121,728invalid character '<' after object key:value pair
4Apr 25, 2026 22:374,50658,512,75424,008,00017,005,00094,609,408
5Apr 25, 2026 22:374,51258,905,63624,040,00017,028,00094,797,824
6Apr 25, 2026 22:374,52256,747,05222,084,00019,073,00094,806,016
7Apr 25, 2026 22:374,52560,048,82524,108,00017,076,00094,777,344
8Apr 25, 2026 22:374,52958,129,77726,136,00015,078,00094,793,728
9Apr 25, 2026 22:374,53459,998,95524,156,00017,111,00094,609,408
10Apr 25, 2026 22:374,54359,308,34821,179,00020,170,00094,789,632
11Apr 25, 2026 22:374,57160,426,37322,782,00018,820,00094,593,024
12Apr 25, 2026 22:374,57359,977,75722,789,00018,826,00094,797,824