I have A method for format the ouput as json. My keyword_filter will be pass in this this format:
<QueryDict: {u'customer_type': [u'ABC'], u'tag': [u'2']}>
<QueryDict: {u'customer_type': [u'TDO'], u'tag': [u'3']}>
<QueryDict: {u'customer_type': [u'FRI'], u'tag': [u'2,3']}>
In fact this I got from request.GET (keyword_filter=request.GET)
This is my method:(I am trying)
def save_fiter_to_JSON(self, dest, keyword_filter):
fwrite = open(dest, 'a')
#keyword_filter = <QueryDict: {u'customer_type': [u'FRI'], u'tag': [u'2,3']}>
string_input1 =string.replace(str(keyword_filter), '<QueryDict:', '["name:"')
string_input2 = string.replace(string_input1, '>', '')
fwrite.write(string_input2+",\n")
fwrite.close()
Everybody here Could help me? The json format That I Want.
[
{"name": filter_name, "customer_type": "ABC", "tag": [2,3]},
]
Or the other good one format from you .
import simplejson as json
>>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
'["foo", {"bar": ["baz", null, 1.0, 2]}]'
**filter_name will be pass from the method save_fiter_to_JSON.
Merry Christmas And a happy New Year. ...