I’m currently testing some Android wrapper updates and hit this error:
2021-09-19 13:27:07.730 27549-27549/com.github.catfriend1.syncthingandroid.debug E/RestApi: getEvents: Skipping event due to JsonSyntaxException, raw=[{"id":20,"globalID":20,"time":"2021-09-19T11:27:03.379654Z","type":"Failure","data":"can't encrypt outgoing data because local data is encrypted (folder-type receive-encrypted)"}]
It doesn’t parse into my error Event.class which is defined like this:
public class Event {
public int id;
public int globalID;
public String type;
public String time;
public Map<String, Object> data;
}
Can we please return some “Map<String, Object>” for “data”?
Alternatively, I would have to try…catch that one exceptional error message and parse it into:
public class Event2 {
public int id;
public int globalID;
public String type;
public String time;
public <String> data;
We’ve never really narrowed down the type for data, in principle it could be anything. Looking at our events it is in practice almost always a map/dictionary/object of some kind, like your definition here, with the failure event being an obvious exception. I don’t think the structure of the failure event is essential, this could probably be changed to a {"message": "..."} type thing instead, and we could tighten up the definition to say that the data is always a Map<String, Something>…
Would that be a lot of work on your side? I think it’s more easy for people that create wrappers or generally interface the API. I’ve also a batch API event reader in the making, so I’d appreciate going this way.
If not, I’ll take @AudriusButkevicius suggestion and check the type of “Object”.