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

broken json #24

Closed
flux242 opened this Issue Sep 17, 2016 · 4 comments

Comments

2 participants
@flux242

flux242 commented Sep 17, 2016

{"pi":"0xd318","group":"3A","tp":"true","prog_type":"Pop Music","open_data_app":{"oda_group":"12A","app_name":"RadioText+ (RT+)"}

there's a missing }

@windytan

This comment has been minimized.

Show comment
Hide comment
@windytan

windytan Sep 17, 2016

Owner

Thanks, fixed.

Owner

windytan commented Sep 17, 2016

Thanks, fixed.

@windytan windytan closed this Sep 17, 2016

@flux242

This comment has been minimized.

Show comment
Hide comment
@flux242

flux242 Sep 17, 2016

you may test the json output using jq command. Example to show the tmc events -
nc -u -l 192.168.1.255 6666 | ./redsea -b | sed -r 's/\/\*[^\/]+.//g'|jq -C --unbuffered -c 'select(.group=="8A")|.tmc.message|select(.location!=null)|[.location,.event_codes,.description]' | awk '{if(old!=$0)print $0;old=$0}'

the sed filter is needed because jq doesn't like comments in the json (like /* TODO */). The awk at the end removes doubles. jq in this example will of course parse the rest and will produce an error if the json is not valid.

flux242 commented Sep 17, 2016

you may test the json output using jq command. Example to show the tmc events -
nc -u -l 192.168.1.255 6666 | ./redsea -b | sed -r 's/\/\*[^\/]+.//g'|jq -C --unbuffered -c 'select(.group=="8A")|.tmc.message|select(.location!=null)|[.location,.event_codes,.description]' | awk '{if(old!=$0)print $0;old=$0}'

the sed filter is needed because jq doesn't like comments in the json (like /* TODO */). The awk at the end removes doubles. jq in this example will of course parse the rest and will produce an error if the json is not valid.

@windytan

This comment has been minimized.

Show comment
Hide comment
@windytan

windytan Sep 17, 2016

Owner

Great tip! I tried jsonlint but it had to be called separately for each line of JSON, and thus there was a lot of overhead. (Just changed -r to -E for BSD sed)

Owner

windytan commented Sep 17, 2016

Great tip! I tried jsonlint but it had to be called separately for each line of JSON, and thus there was a lot of overhead. (Just changed -r to -E for BSD sed)

@flux242

This comment has been minimized.

Show comment
Hide comment
@flux242

flux242 Sep 17, 2016

you are welcome! Thanks for the great program

flux242 commented Sep 17, 2016

you are welcome! Thanks for the great program

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