Open EstoyAburrido opened 3 years ago
Try json serializing the response type to see if it contains the expected fields and search further from there.
If I manually remove empty fields in UnmarshalRequest at https://github.com/voltbras/go-ocpp/blob/master/ws/message.go everything works as expected.
removing the file go-ocpp/messages/v1x/cpreq/json_encode.go also fixes all the problems, I have no idea what was this file meant to do but all it does is adding empty values to the query instead of omitting them
The json_encode file was auto-generated based on the OCPP JSON Schema, it also validates required properties, timestamp formats, etc. I also see that it doesn't correctly handle empty fields(even though it is annotated). Howerver, that file is still useful because, as I said, when unmarshalling, it validates all those JSON Schema constraints defined per action, however it does seem that we could remove the MarshalJSON functions, as the default MarshalJSON implementation seems sufficient and correct. I just feel that we needed to have this tested a bit more, before I can say that this change wouldn't break anything.
Also, please feel free to contribute to this library! Any help is appreciated!
Hi. I'm trying to send a request as follows:
And StopTransaction struct has 'omitempty' json parameters on each non-required field but when I send the request the server(which is not based on the same library) gets this:
"StopTransaction",{"idTag":"","meterStop":13740,"reason":"Remote","timestamp":"2020-12-03T20:41:33+03:00","transactionData":null,"transactionId":1}
It complains about transactionData and replying with the following error message:
As you can see all the other optional fields are also included in the query.
Any idea how do I send the request omitting optional values ?