What is the Python equivalent of StringEntity in Java? -


i have following class in java:

class jsonentity extends stringentity {     private final string string;      public jsonentity(string string, charset charset) {         super(string, contenttype.create(contenttype.application_json.getmimetype(), charset));         this.string = string } 

i have no clue how implement above code in python 2.7. there way can achieve this?

i don' know if need, if need save json particular charset in python can this:

import json  json_string = json.dumps("your string wierd symbols", ensure_ascii=false).encode('utf8') 

nb: can change utf8 other charsets.

edit: anyway if need extend implement json reader/writer can extend jsonencoder: https://docs.python.org/2.6/library/json.html#json.jsonencoder


Comments