I am trying to do something similar in Python like NewtonSoft
is doing in C#
.
I have the following JSON file:
{
"lead": {
"Id": "abc",
"CreateDate": "2020-16-04T17:55:47.229554",
"Source": "Source"
},
"cars": [
{
"Id": 1,
"Year": "1951",
"Make": "Willys"
},
{
"Id": 2,
"Year": "1950"
}
],
"Client": {
"LeadId": "ca5326c1fa14475ea6e8106c8c4a3d9d",
"FirstName": "Christopher",
"LastName": "Murphy"
}
}
If I serialize the JSON and use NewtonSoft
in C#
then I get the following result:
"{\"lead\":{\"Id\":\"abc\",\"CreateDate\":\"2020-16-04T17:55:47.229554\",\"Source\":\"Source\"},\"cars\":[{\"Id\":1,\"Year\":\"1951\",\"Make\":\"Willys\"},{\"Id\":2,\"Year\":\"1950\"}],\"Client\":{\"LeadId\":\"ca5326c1fa14475ea6e8106c8c4a3d9d\",\"FirstName\":\"Christopher\",\"LastName\":\"Murphy\"}}"
But the dump
and dumps
methods are giving other results in Python, Is there other way to achieve the same result in python?