broken json #24

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

Projects

None yet

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
Owner

Thanks, fixed.

@windytan windytan closed this Sep 17, 2016
@flux242
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
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)

@flux242
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