Created
          December 22, 2011 22:05 
        
      - 
      
- 
        Save dsc/1512055 to your computer and use it in GitHub Desktop. 
    Python JSON decoder that uses OrderedDict for JSON Objects.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import json | |
| from collections import OrderedDict | |
| ordered_decoder = json.JSONDecoder(object_pairs_hook=OrderedDict) | |
| class OrderedJSONDecoder(json.JSONDecoder): | |
| """ As `JSONDecoder`, but passing `collections.OrderedDict` | |
| for `object_pairs_hook` by default. | |
| """ | |
| def __init__(self, | |
| encoding=None, | |
| object_hook=None, | |
| parse_float=None, | |
| parse_int=None, | |
| parse_constant=None, | |
| strict=True, | |
| object_pairs_hook=OrderedDict | |
| ): | |
| super(OrderedJSONDecoder, self).__init__( | |
| encoding=encoding, | |
| object_hook=object_hook, | |
| parse_float=parse_float, | |
| parse_int=parse_int, | |
| parse_constant=parse_constant, | |
| strict=strict, | |
| object_pairs_hook=object_pairs_hook | |
| ) | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Cara decode nya gimana bang