0

I've got a log file as JSON that includes unsupported types, even though the intention was apparently to have something human editable and I wish this log file was never produced, what would be the appropriate way?

The Log file has entry's as following, basicly non string,dict,tuple,..:

{"a":float(9)}

the only way I've found is using the eval which does the job but there must be a better way? Ast.literal_eval won't work as it will fail with "malformed string"

user1767754
  • 23,311
  • 18
  • 141
  • 164
  • But I am not looking in deriving from JSON to write my own serialization. For every class you would have to write it, i am looking for a more generic solution. – user1767754 Oct 25 '17 at 19:01
  • This is a generic solution, or you'll have to come up with a nifty way to make it generalized based on the data you got. The problem is that this is deviant behavior, either fix the root cause to why the data looks like this. Or you need to write deserialization triggers that match your data. Either way, this is not standard data - hence there's no standard solution. – Torxed Oct 25 '17 at 19:40
  • I agree and i am not a friend of hacks/monkey patching, However if you are dealing with data, that was generated 10 years ago, you cannot fix the root cause but at least try to align it in the most elegant way possible within the margin. – user1767754 Oct 25 '17 at 20:35

0 Answers0