How to read JSON

How to read JSON

First, read the file normally

with open('test.json', 'r') as f:
	js=f.read()

When instructed to load as json

import json
nb=json.loads(js)

Easy to handle as a dictionary format! It can be used to store external parameters

print(nb)
#[Out]#{'color_scheme': 'Packages/User/Tubnil_kai (SL) (SublimePythonIDE).tmTheme', 'enable_tab_scrolling': True, 'detect_slow_plugins': False, 'always_show_minimap_viewport': True, 'draw_white_space': 'all', 'draw_minimap_border': True, 'file_exclude_patterns': ['*.exe', '*.zip', '*.lnk', '*.db', '*.pptm', '*.docx', '*.pdf', '*.dwt', '*.bak', '*.xlsx', '*.ex4', '*.ex4old']}

print(nb['color_scheme'])
#[Out]#Packages/User/Tubnil_kai (SL) (SublimePythonIDE).tmTheme

print("*.exe" in nb['file_exclude_patterns'])
#[Out]#True

It seems that you can read directly from the file if it is json.load () instead of json.loads () Can be shortened!

import json
with open('test.json', 'r') as f:
    nb=json.load(f)
print(nb)

Recommended Posts

How to read JSON
How to read PyPI
How to read e-Stat subregion data
How to read the SNLI dataset
How to read pydoc on python interpreter
How to read CSV files in Pandas
How to read problem data with paiza
How to use xml.etree.ElementTree
How to use Python-shell
How to read a CSV file with Python 2/3
How to use tf.data
How to use virtualenv
Scraping 2 How to scrape
How to use image-match
How to use shogun
How to install Python
How to use Pandas 2
How to install pip
How to use Virtualenv
How to use numpy.vectorize
How to update easy_install
How to install archlinux
How to use pytest_report_header
[Python] How to read excel file with pandas
How to restart gunicorn
How to install python
How to virtual host
[Python] How to read data from CIFAR-10 and CIFAR-100
How to use partial
How to use Bio.Phylo
How to make scrapy JSON output into Japanese
How to generate a Python object from JSON
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to update Spyder
[Introduction to Python] How to handle JSON format data
How to use IPython
How to read an array with Python's ConfigParser
How to install BayesOpt
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
I read "How to make a hacking lab"
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to read time series data in PyTorch
How to grow dotfiles
How to use list []
Convert json to excel
How to use python-kabusapi
"How to count Fukashigi"
How to install Nbextensions
How to use OptParse
Tensorflow, Tensorflow After all, which one (How to read Tensorflow)
How to use return
How to install Prover9
How to use dotenv