This example describes the Python simple read JSON file feature. Share to everyone for your reference, specific as follows:
Read_json.json:
{"Rule
": {"
namespace": "Strategy",
"name": "test_exp_1496234234223400",
"version": 0,
"last_ Modify_time ": 1434234236819000,
" log_rate ": 1023300,
" schema_version ":" hello_world! "
}
read_json.py:
#-*-Coding:utf-8-*-
import JSON
with open ("Read_json.json", ' R ') as f:
temp = json.loads (F.read ())
print (temp)
print (temp[' rule ')
print (temp[' rule ' [' namespace '])
Run Result:
{u ' rule ': {u ' name ': U ' test_exp_1496234234223400 ', U ' log_rate ': 1023300, U ' namespace ': U ' strategy ', U ' schema_version ': U ' hello_world! ', U ' last_modify_time ': 1434234236819000L, U ' version ': 0}}
{u ' name ': U ' test_exp_1496234234223400 ' , u ' log_rate ': 1023300, U ' namespace ': U ' strategy ', U ' schema_version ': U ' hello_world! ', U ' last_modify_time ': 1434234236819000L, U ' version ': 0}
Strategy
PS: About JSON operation, here we recommend a few more practical JSON online tools for your reference to use:
online JSON code inspection, inspection, landscaping, formatting tools:
Http://tools.jb51.net/code/json
JSON Online formatting tools:
Http://tools.jb51.net/code/jsonformat
Online Xml/json Mutual conversion tool:
Http://tools.jb51.net/code/xmljson
JSON code online Format/beautify/compress/edit/Convert tool:
Http://tools.jb51.net/code/jsoncodeformat
Online JSON compression/Escape tool:
Http://tools.jb51.net/code/json_yasuo_trans