Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array parsing in JSON #9

Closed
Aquesta opened this issue Aug 28, 2023 · 13 comments
Closed

Array parsing in JSON #9

Aquesta opened this issue Aug 28, 2023 · 13 comments
Milestone

Comments

@Aquesta
Copy link

Aquesta commented Aug 28, 2023

I have Json:
{ "info": { "id": 3569, "game": "basketball", "title": "УЛМ vs ТИМ", "round_number": 2, "matchround_id": 2222, "tournament_id": 192 }, "teams": [ { "id": 238, "sort": 1, "info": { "title": "УЛМ", "title_en": "УЛМ", "color": null, "disqualification": false }, "statistic": { "currentRound": { "id": 2, "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "penalty_goal": 0, "timeout": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0 }, "match": { "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "match_win": 0, "penalty_goal": 0, "timeout": 0, "match_lose": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0, "id": 3569, "rounds": [ { "id": 1, "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "penalty_goal": 0, "timeout": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0 } ], "goal": 0 }, "matchround": { "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "match_win": 0, "penalty_goal": 0, "timeout": 0, "match_lose": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0, "total_shot": 0, "id": 2222, "goal": 0 }, "tournament": { "goal": 0 } }, "athletes": [ { "id": 873, "sort": 1, "info": { "name": "Данилюк В.А.", "name_en": "Данилюк В.", "nickname": null, "slot": null, "disqualification": false, "number": 1, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } }, { "id": 871, "sort": 2, "info": { "name": "Зайнов Е.В.", "name_en": "Зайнов Е.", "nickname": null, "slot": null, "disqualification": false, "number": 4, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } }, { "id": 871, "sort": 3, "info": { "name": "Зайнов Е.В.", "name_en": "Зайнов Е.", "nickname": null, "slot": null, "disqualification": false, "number": 3, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } }, { "id": 875, "sort": 4, "info": { "name": "Новоселов Н.А.", "name_en": "Новоселов Н.", "nickname": null, "slot": null, "disqualification": false, "number": 2, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } } ] }, { "id": 236, "sort": 2, "info": { "title": "ТИМ", "title_en": "ТИМ", "color": null, "disqualification": false }, "statistic": { "currentRound": { "id": 2, "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "penalty_goal": 0, "timeout": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0 }, "match": { "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "match_win": 0, "penalty_goal": 0, "timeout": 0, "match_lose": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0, "id": 3569, "rounds": [ { "id": 1, "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "penalty_goal": 0, "timeout": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0 } ], "goal": 0 }, "matchround": { "team_foal": 0, "1_point_goal": 0, "2_point_goal": 0, "team_rebound": 0, "match_win": 0, "penalty_goal": 0, "timeout": 0, "match_lose": 0, "1_point_shot": 0, "miss_-1": 0, "challenge": 0, "miss_-2": 0, "penalty_miss": 0, "2_point_shot": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "point": 0, "media_timeout": 0, "total_shot": 0, "id": 2222, "goal": 0 }, "tournament": { "goal": 0 } }, "athletes": [ { "id": 873, "sort": 1, "info": { "name": "Данилюк В.А.", "name_en": "Данилюк В.", "nickname": null, "slot": null, "disqualification": false, "number": 8, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } }, { "id": 872, "sort": 2, "info": { "name": "Иванов Д.О.", "name_en": "Иванов Д.", "nickname": null, "slot": null, "disqualification": false, "number": 7, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } }, { "id": 871, "sort": 3, "info": { "name": "Зайнов Е.В.", "name_en": "Зайнов Е.", "nickname": null, "slot": null, "disqualification": false, "number": 6, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } }, { "id": 875, "sort": 4, "info": { "name": "Новоселов Н.А.", "name_en": "Новоселов Н.", "nickname": null, "slot": null, "disqualification": false, "number": 5, "position": null, "reserve": false }, "statistic": { "currentRound": { "id": 2, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 }, "match": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 3569, "rounds": [ { "id": 1, "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0 } ] }, "matchround": { "1_point_goal": 0, "2_point_goal": 0, "penalty_goal": 0, "miss_-1": 0, "1_point_shot": 0, "miss_-2": 0, "2_point_shot": 0, "penalty_miss": 0, "turnover": 0, "block": 0, "rebound": 0, "pass": 0, "foal": 0, "dsql_foal": 0, "id": 2222 } } } ] } ] }

and then i did that i have error:
Monosnap HTTP Request Builder 2023-08-28 11-28-54

@royshil
Copy link
Collaborator

royshil commented Aug 28, 2023

The teams is an array so you need to do something like /teams/0/statistics/... to capture the first entry in the array

@royshil
Copy link
Collaborator

royshil commented Sep 11, 2023

@Aquesta is this problem still pending? otherwise we will close the issue

@Destroy666x
Copy link
Contributor

Perhaps an idea here is to support arrays (whether with current way or with e.g. JSONPath) and add settings like:

  • how each piece should display (in case result is array of objects), e.g. {prop1} - {prop2}
  • separator to merge pieces, e.g. |

@royshil royshil changed the title How to parse massives from JSON? Array parsing in JSON Sep 30, 2023
@royshil royshil added this to the 0.1.1 milestone Oct 3, 2023
@royshil
Copy link
Collaborator

royshil commented Oct 4, 2023

implemented in #30

@royshil
Copy link
Collaborator

royshil commented Oct 4, 2023

@Destroy666x @Aquesta are you all able to test the artifacts on #30 to see that it works for you? 🙏

@Destroy666x
Copy link
Contributor

Destroy666x commented Oct 4, 2023

Something's not right. E.g. this https://amock.io/api/testest with $.something doesn't return anything. Would also be nice to see the mentioned separator option (as formatting each item, especially object, is harder to achieve I'm pretty sure).

Test request also doesn't return anything.

EDIT: it started working randomly. The output looking like ["Something!", ... , "Sure!"] isn't great though.

EDIT: as for earlier errors, there were:

20:19:35.716: [obs-urlsource] Failed to send request: [json.exception.parse_error.101] parse error at line 1, column 28: syntax error while parsing array - invalid literal; last read: '"Awesome!".'; expected ']'

which is really weird as I didn't change the endpoint (you can't) and there's JSON validation from what I've seen. Maybe the service had some bug, I don't know. But seems to work consistently now.

@Destroy666x
Copy link
Contributor

Another small issue I noticed is that the URL isn't reflected correctly in the main properties window once you save. It gets updated to new URL once you reopen the Setup Data Source window.

@Destroy666x
Copy link
Contributor

Destroy666x commented Oct 4, 2023

One more thing I tried - don't know which JsonPath features are supposed to be supported as of now, but e.g. union isn't: $..['fact','length'] (with the default cat API). It shows some valid data within request testing window, but then outputs {output}

@royshil
Copy link
Collaborator

royshil commented Oct 4, 2023

For multiple outputs now you have {output0} {output1} etc.
I haven't explored unions yet.

I think maybe a {output["field"]} or {output.field} type of interaction is possible

@Destroy666x
Copy link
Contributor

Destroy666x commented Oct 4, 2023

Oh ok, so if there are multiple cells shown in the test, variables change then? I see. Could add some headers with var names above these cells in that case. And perhaps even change {output} to {output0} automatically in the setting (or {output} could just be output0 by default).

That works with unions too, confirming.

@royshil
Copy link
Collaborator

royshil commented Oct 4, 2023

image
this is what i have - looks ok?

@royshil
Copy link
Collaborator

royshil commented Oct 4, 2023

@Destroy666x can you test out #30 artifacts?

@royshil
Copy link
Collaborator

royshil commented Oct 5, 2023

closing. merged #30

@royshil royshil closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants