Html Tags Within Json (in Python)
I understand its not a desirable circumstance, however if I NEEDED to have some kind of HTML within JSON tags, e.g.: { 'node': { 'list':'
- >Hello World</li><ul>"
}
}
However, with
simplejson
, which is built into Python 2.6 as the json module, it does any escaping you need automatically:>>> import simplejson >>> simplejson.dumps({'node': {'list': '<ul><liclass="lists">Hello World</li><ul>'}}) '{"node": {"list": "<ul><liclass=\\"lists\\">Hello World</li><ul>"}}'
Post a Comment for "Html Tags Within Json (in Python)"