Why is my JSON returning a list instead of a single object? How to handle it?

18 Replies, 1272 Views

json returning list issues are the bane of my existence. One thing to try: see if the API has a “single result” flag or param. Some APIs let you specify whether you want a list or a single object.

If not, maybe the API is just poorly designed. In that case, yeah, grabbing the first item is a workaround, but it’s not ideal. You could also write a wrapper function to handle the json returning list case and return the first item if the array length is 1.

Messages In This Thread



Users browsing this thread: 1 Guest(s)