fulldecent / corelocationcli

Command line program to print location information from CoreLocation
MIT License
217 stars 29 forks source link

broken JSON output #19

Closed derhuerst closed 4 years ago

derhuerst commented 6 years ago

A multi-line address in the JSON output breaks it. Valid JSON requires line breaks to be encoded.

In general, it's considered bad practice not to encode JSON. Always encode it using a library/builtin.

derhuerst commented 6 years ago

An example:

{
  "latitude": 1.234,
  "longitude": 4.321,
  "altitude": 1234,
  "direction": -1.0,
  "speed": -1,
  "h_accuracy": 72,
  "v_accuracy": 12,
  "time": "2018-02-06 19:10:42 +0000",
  "address": "Some Road 12
12345 Some City
Germany"
}
derhuerst commented 6 years ago

FYI kiliankoe/location is an alternative that has correct json encoding.

fulldecent commented 6 years ago

Thank you. Yes, valid issue.

JayBrown commented 6 years ago

Noticed the same today. Until now I had only used default output, then used lat+long to get the address using mapbox. But then I tried the -json option to get the address directly, and parsing didn't work:

CoreLocationCLI -json | jq -r '.latitude'
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 12, column 8
fulldecent commented 4 years ago

Fixed in latest version. Requesting testing.

Will need to compile from source because this latest update is not yet in Homebrew.