Problem with Parsing?
Here is what the JSON looks like:
This first screenshot parses correctly
This second screenshot gives me this error:
Exception: Unable to locate var: all_data.totals.statistics.pitching
Why is this behaving as such? It makes no logical sense to me.
Comments
-
Hi @rlove both screenshots are the same, is this intentional?
The unable to locate var error happens when the variable is not found at this path. This can often happen when working with external data because not every response is the same. The quick solution is to use the GET filter instead of dot notation so that you can define a default value when the hard-coded path on the variable does no exist.
-
Hi @rlove, Michael's comment will stop the error, but it looks from your message that the pitching should be in the all_data set. If that's the case (e.g. we are iterating over National League pitchers) maybe you could show what Xano sees right before that line, either from the debugger or by adding a stop-and-debug that displays all_data?
A possible situation is that this is inside an array, and all_data is gathered within the array loop. If you were looping over the players of a baseball team, you might find that they all have hitting stats, but only pitchers have pitching stats. So the "all_data" for the pitcher would have both hitting and pitching, but for the first baseman, there would only be hitting. In that case, you would want either to use the get filter like Michael describes or handle the difference in stats for a given position with more nuanced business logic.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback