Closed derhuerst closed 4 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"
}
FYI kiliankoe/location is an alternative that has correct json encoding.
Thank you. Yes, valid issue.
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
Fixed in latest version. Requesting testing.
Will need to compile from source because this latest update is not yet in Homebrew.
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.