Questions
In the process of using JSON. Dumps (param)
to convert Python objects to JSON, the following problems appear: typeerror: object of type Int64 is not JSON serializable
type
The code is as follows:
param = {
'remoteId': 'remoteId',
'fieldCode': 'fieldCode',
'paramName': 'paramName',
'operation': 'operation',
'operationName': 'operationName',
'paramValue': 0
}
...
json.dumps(param)
Why
0 in 'paramvalue ': 0
is converted into Int64 object by pandas, which is not recognized by JSON library
Solution
Change the Int64 object into a normal string type. As follows:
'paramValue': str(0)
or
df['paramValue'].apply(str)
Similar Posts:
- [Solved] TypeError: string indices must be integers, not str
- TypeError: Object of type ‘datetime‘ is not JSON serializable [Solved]
- How to Solve Error: Unexpected token o in JSON at position 1
- TypeError: Object of type ‘int32’ is not JSON serializable
- [Solved] Python Error: datetime.datetime is not JSON serializable
- Python: json:json.decoder.JSONDecodeError: Invalid control character at: line 2 column 18 (char 19)
- Python JSON error json.decoder.jsondecodeerror Chinese
- System.Data.SqlClient.SqlCommand
- When parsing background JSON data with Ajax: unexpected token o in JSON at position 1