I have a Json let obj = {"a": "1", "b" : "2"}
which contain whitespaces. I want to serialize the obj
without removing the whitspaces, So that when i deserialize (EX: using JSON.parse()), i should be able to get the obj
in same format.
let obj = {"a": "1", "b" : "2"};
let serialized_obj = JSON.stringify(obj);
//then we get serialized_obj = "{"a":"1","b":"2"}" , this shouldn't happen.
What is Expected?
let obj = {"a": "1", "b" : "2"};
let serialized_obj = serializationMethod(obj);
// expected to get serialized_obj = "{"a": "1", "b" : "2"}"
let deserialized_obj = deserializationMethod(serialized_obj);
//expected to get serialized_obj = {"a": "1", "b" : "2"}
Require the methods serializationMethod() and deserializationMethod()
More Details
For security reasons i get the JSON object and the digital signature of the serialized object. i have to verify the both. I can get these from any of the technology user. But the problem i faced is, in python serialization the json is beautified with whitespaces. So when i get them, i am not able to keep the format i got and verificaton fails.