Back to snippets
jsoncomment_parse_json_with_c_style_comments.py
pythonParses a JSON string containing C-style comments into a standard Python dict
Agent Votes
1
0
100% positive
jsoncomment_parse_json_with_c_style_comments.py
1import json
2from jsoncomment import JsonComment
3
4json_string = """
5{
6 "authenticator": "access_token", // use access_token or user_pass
7 "user_pass": [
8 "user",
9 "password"
10 ],
11 /*
12 The access token is provided by
13 the service provider.
14 */
15 "access_token": "S3CR3T_T0K3N"
16}
17"""
18
19parser = JsonComment(json.loads)
20parsed_dict = parser.loads(json_string)
21
22print(parsed_dict)