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 22, 2024 02:21Yuriy LyfenkoYuriy LyfenkoScore: 3,705Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 22, 2024 02:213,676592,207,18333,454,237094,625,792
2Apr 22, 2024 02:213,678590,757,74633,474,287094,613,504
3Apr 22, 2024 02:213,684562,716,25725,397,0008,127,00092,897,280
4Apr 22, 2024 02:213,695565,844,67724,725,0008,901,00092,909,568
5Apr 22, 2024 02:213,696563,429,74724,729,0008,902,00092,872,704
6Apr 22, 2024 02:213,699602,282,17633,660,794094,621,696
7Apr 22, 2024 02:213,705558,902,81324,794,0008,925,00092,860,416
8Apr 22, 2024 02:213,705562,220,64424,794,0008,926,00092,921,856
9Apr 22, 2024 02:213,709562,806,42825,810,0007,941,00092,889,088
10Apr 22, 2024 02:214,302560,690,46226,785,00012,362,00092,958,720
11Apr 22, 2024 02:214,338568,646,89024,293,00015,183,00092,893,184
12Apr 22, 2024 02:214,497567,476,86027,999,00012,923,00092,958,720