Skip to content

Error during deserializing devices #4

Closed

Description

@insane4sure

Looks like my zones (stickup cam) aren't formatted as expected. GetRingDevices() triggers an exception:

the current JSON array (e.g. [1,2,3]) into type 'KoenZomers.Ring.Api.Entities.MotionZone' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path 'stickup_cams[0].settings.motion_zones', line 1, position 3978.'

The offending json response looks like this:
"motion_zones": [ 1, 1, 1, 1, 1 ],

I temporarily worked around it by ignoring deserialzation errors

var settings = new JsonSerializerSettings { Error = (se, ev) => { ev.ErrorContext.Handled = true; } };
var devices = JsonConvert.DeserializeObject<Entities.Devices>(response, settings);

Activity

  1. self-assigned this
    on Dec 23, 2019
  2. KoenZomers commented on Dec 23, 2019

    @KoenZomers
    Owner

    Following your recommendation here to make the JSON parsing less strict on all returned responses from Ring to avoid the entire API not being able to be used anymore on the slightest differences. As the Ring API is not supported nor documented, it may change at any time and based on what I've seen it does do so. So this in my opinion justifies this kind of handling.

    Thanks for your recommendation.

    Released in version 0.4.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions