Multi dimensional array in JQ

V J

Can some one please help to transform the input json to output format like i specified below . i tried multiple ways but i could not succeed.

I have input :

 {
        "hosts": [
            {
                "statistics": [
                    {
                        "timestamp": {
                            "date": "2017-06-09",
                            "time": "21:40:01"
                        },
                        "cpu-load": [
                            {
                                "idle": 99.64
                            }
                        ]
                    }
                ]
            }
        ]
    }

I need output :

{

    "hosts": [
        {
            "statistics": [
                {
                    "timestamp": "2017-06-09 21:40:01",
                    "cpu-load": [
                        {
                            "idle": 99.64
                        }
                    ]
                }
            ]
        }
    ]
}
user197693

The update operator |= should do the trick.

jq '.hosts[].statistics[].timestamp |= .date + " " + .time'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related