michalmuskala / jason

A blazing fast JSON parser and generator in pure Elixir.
Other
1.6k stars 170 forks source link

Remove scaping caracters when enconding Keyword list #118

Closed ochoadev closed 3 years ago

ochoadev commented 3 years ago

I have been trying to encode a keyword list that follows the next structure:

[ patente: "#{d.lpf.plate}", fecha_hora: get_date_time_formatted(d.lpf.gps_date), latitud: String.replace("#{d.lpf.lat}", ".", ","), longitud: String.replace("#{d.lpf.lng}", ".", ","), direccion: "#{abs(d.lpf.direction)}", velocidad: "#{d.lpf.velocity}", estado_registro: "1", estado_ignicion: get_ignition_status(d.lpf.ignition), numero_evento: "45" ]

I have been using Jason.Helpers.json_map and then Json.encode!

I do this encoding because I'm making a post request with the body above. I didn't use a map because params orders matters, but when the request hits the host the body its the following:

"{\"patente\":\"LJKW-83\",\"fecha_hora\":\"2020-10-05 21:01:50\",\"latitud\":\"-30,6066685\",\"longitud\":\"-71,1941376\",\"direccion\":\"222\",\"velocidad\":\"0.0\",\"estado_registro\":\"1\",\"estado_ignicion\":\"0\",\"numero_evento\":\"45\"}",

I don't want to have a "json" that is really a string and have \ inside.

michalmuskala commented 3 years ago

I'm not sure I understand what the issue is. Could you provide an example that reproduces it, I could execute?

michalmuskala commented 3 years ago

Given no new input, I'm going to close this. If you have more information I could use to follow-up, feel free to re-open.