奇怪的JSON解析

奇怪的JSON解析,json,Json,我必须在Python3中加载此JSON代码: {'code': 161, 'message': "You are unable to follow more people at this time. Learn more <a href='http://support.twitter.com/articles/66885-i-can-t-follow-people-follow-limits'>here</a>."} 这将替换所有的“by”。它适用于大多数错误消息,但上

我必须在Python3中加载此JSON代码:

{'code': 161, 'message': "You are unable to follow more people at this time. Learn more <a href='http://support.twitter.com/articles/66885-i-can-t-follow-people-follow-limits'>here</a>."}
这将替换所有的“by”。它适用于大多数错误消息,但上面的一条根本不起作用,因为消息中的链接中存在“by”。 现在我不想加载这个JSON

你能想出一个解决办法吗


Lyxilion.

“我必须用Python加载这个JSON代码”不是。如果是,你就不必用
”替换
。至少相关:你的基本问题是:“如何用
”替换
,除非已经用引号括起来的字符串?”这个问题展示了如何做到这一点(使用
|
而不是
,但是…。在收到无效的JSON后尝试修复它只能是痛苦的。你应该让负责发送损坏数据的人向你发送有效的JSON。实际上是Twitter破坏了JSON。。。
errorLog = json.loads(str.replace(str(error.message[0]), "'", '"'))