How to parse json file with c-style comments?

后端 未结 5 1340
無奈伤痛
無奈伤痛 2020-12-03 10:19

I have a json file, such as the following:

    { 
       \"author\":\"John\",
       \"desc\": \"If it is important to decode all valid JSON correctly \\ 
an         


        
5条回答
  •  情话喂你
    2020-12-03 10:23

    jsoncomment is good, but inline comment is not supported.

    Check out jstyleson, which support

    • inline comment
    • single-line comment
    • multi-line comment
    • trailing comma.

    Example

    Install

    pip install jstyleson

    Usage

    import jstyleson
    result_dict = jstyleson.loads(invalid_json_str) # OK
    jstyleson.dumps(result_dict)
    

提交回复
热议问题