json-rust icon indicating copy to clipboard operation
json-rust copied to clipboard

Allow parsing series of json documents

Open pavelmachek opened this issue 7 years ago • 1 comments

I'm trying to parse json data from gpsd. Gpsd provides series of jsons over the socket:

{"class":"TPV","tag":"GLL","device":"/dev/pts/17","mode":2,"time":"2016-02-12T15:45:52.000Z","ept":0.005,"lat":48.268635783,"lon":14.211360400,"speed":70.000} {"class":"TPV","tag":"GGA","device":"/dev/pts/17","mode":3,"time":"2016-0212T15:45:52.000Z","ept":0.005,"lat":48.268635783,"lon":14.211360400,"alt":7.000,"epv":115.000,"speed":70.000} {"class":"TPV","tag":"RMC","device":"/dev/pts/17","mode":3,"time":"2016-02-12T15:45:52.000Z","ept":0.005,"lat":48.268635783,"lon":14.211360400,"alt":7.000,"epv":115.000,"track":195.8000,"speed":70.016,"climb":0.000}

Unfortunately, json::parse does not return "how many bytes it parsed" so I could skip first message and ask it to parse second one. Could such functionality be added?

pavelmachek avatar May 31 '18 19:05 pavelmachek

Why don't you just parse each of socket.lines()?

njaard avatar Mar 26 '19 18:03 njaard