Reduce json response from curl command

It might be a stupid question, but I am brave enough to ask it anyway:

I am retrieving trip information of my volvo using the voc script from github

For requesting the trips I get a response with the entire list of my trips.
This leads to a timeout in my rule with a timeout of 10 seconds.

 "trips": [
        {
            "tripDetails": [
                {
                    "electricalConsumption": 0,
                    "startPosition": {
                        "longitude": x.xxx,
                        "streetAddress": "Some Street",
                        "city": "Some City",
                        "ISO2CountryCode": "DE",
                        "postalCode": "xxxxx",
                        "Region": "Some Region",
                        "latitude": x.xxx
                    },
                    "fuelConsumption": 64,
                    "startTime": "2018-09-06T16:43:22+00:00",
                    "startOdometer": 26766958,
                    "endTime": "2018-09-06T16:59:47+00:00",
                    "endOdometer": 26775434,
                    "distance": 8476,
                    "endPosition": {
                        "longitude": xxx,
                        "streetAddress": "Some other Street",
                        "city": "Same City",
                        "ISO2CountryCode": "DE",
                        "postalCode": "xxxxx",
                        "Region": "Same Region",
                        "latitude": x.xxx
                    },
                    "electricalRegeneration": 0
                }
            ],
            "name": null,
            "userNotes": null,
            "id": 970132060,
            "trip": "https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/xxx/trips/970132060",
            "category": "unassigned"
        },
        {
            "tripDetails": [

Now my question:
Is it possible to stop receiving the response as soon as the second “tripDetails” appears or is this purely server related and I need to figure out how to retrieve the trip data for a single trip (by ID ??)?

I would suggest to split the calling of the web service and the parsing of the json file. Setup a cron task in your os, which requests the trips and saves as file every hour or once a day, depending on your needs.

Do your openHAB parsing on top of this file, also depending on your needs.

No, you can’t. You either get the complete answer or none at all. You also do not have a valid json file when you just receive some bits of the file.

I notice that that script supports MQTT. Have you looked into letting this script run independently and report the information to OH over MQTT? That would completely move the timing issues out of OH.

That’s a good Point.
I do not use mqtt yet except for OwnTracks, but I will consider your suggestions.

In this case i would still receive the entire string, right?
What’s the difference then in terms of performance?

I’ve no idea. I just saw that there is an MQTT option. It might publish the different pieces of data to different topics. You will have to read the docs for the script to learn how the data gets published.

You almost never have to worry about performance in general in this problem space. Even a Raspberry Pi 2 is more than up to the task of processing much longer JSON strings than the example you posted above.

However, where you are having problems is with how long it takes to retrieve the data and by running the script separately from OH, that wait time is no longer OH’s problem and the Python script probably doesn’t care. So it’s a good way to solve your problem.

I get your point and will consider to outsource it to a local script then.
Thanks, Rich