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 listMay 26, 2021 02:54Yuriy LyfenkoYuriy LyfenkoScore: 15,212Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 26, 2021 02:5410,886165,613,87799,063,340094,666,752
2May 26, 2021 02:5410,919174,069,64299,361,010094,683,136
3May 26, 2021 02:5410,948181,110,86899,623,360094,769,152
4May 26, 2021 02:5415,160164,586,65990,969,00046,984,00094,613,504
5May 26, 2021 02:5415,185161,369,68392,123,00046,061,00094,699,520
6May 26, 2021 02:5415,206162,246,47781,220,00057,155,00094,617,600
7May 26, 2021 02:5415,212169,361,08089,278,00049,153,00094,666,752
8May 26, 2021 02:5415,219165,249,02595,337,00043,152,00094,711,808
9May 26, 2021 02:5415,258170,681,47895,895,00042,953,00094,613,504
10May 26, 2021 02:5415,267162,813,84096,950,00041,978,00094,633,984
11May 26, 2021 02:5415,581167,294,74082,874,00058,910,00093,097,984
12May 26, 2021 02:5415,976168,422,55886,226,00059,155,00093,310,976