lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
262 stars 125 forks source link

EscapeHTML configuration for json.Marshal #168

Closed singhashmeet closed 1 year ago

singhashmeet commented 1 year ago

Currently the standard library "encoding/json" is being used to send messages. The library by default escapes a string as mentioned here https://pkg.go.dev/encoding/json#HTMLEscape While sending a URL to the charger or any other string that has symbols like & in them they are escaped and the chargers are not able to parse them correctly. For example if you send a firmware update with a URL like https://someUri?param1=123&param2=7363&something=else It is escaped to https://someUri?param1=123\u0026param2=7363\u0026something=else which the charger will not be able to download and the update fails.

This change adds a flag and implements a custom jsonMarshal method to provide additional functionality for handling issues like this

lorenzodonini commented 1 year ago

Hey there, I didn't encounter this use-case before but it's definitely a nice addition. Thanks for submitting the PR 👍

lorenzodonini commented 1 year ago

Just fyi, I added a patch in https://github.com/lorenzodonini/ocpp-go/pull/174 to fix an issue with trailing newlines.