Alex Rivera | Logout

Python: Change list type for json decoding

Asked 2012-06-04T17:09:07.600
9

in Python 2.7+ I can use the object_pairs_hook in the builtin json module to change the type of the decoded objects. Is there anyway to do the same for lists?

One option is to go through the objects that I get as arguments to the hook and replace them with my own list type, but is there any other, smarter way?

Edit
Report

1 Answer

1

According to source code it is not possible: C-level function explicitly instantiates the built-in list type without using any callbacks/hooks. The same in trunk.

answered 2012-06-04T21:05:58.570

Your Answer