Python #JSON

Learning memo / memorandum

JSON A language that becomes a data exchange format between various programming languages. Even in Python, JSON can be handled using the json package that is supported as standard.

Encode to Python data

import json

with open('test.json', 'r') as j:
    data = json.loads(j.read())

Write to JSON file

import json

data = ['I love', 
        {'language':  {'target': ['Python', 'Java', 'JavaScript']}},
        {'alcohol': {'target': ['Beer', 'Wine', 'Whisky']}}
       ]

with open('test.json', 'w') as j:
    j.write(json.dumps(data)) 

Recommended Posts

Python #JSON
[Python] Use JSON with Python
Python
Handling json in python
json
json
Easily format JSON in Python
POST json with Python3 script
[Python] JSON validation using Voluptuous
Format json with Vim (with python)
Read json data with python
kafka python
Python Summary
Built-in python
Python comprehension
Python technique
Studying python
Python 2.7 Countdown
Python FlowFishMaster
Python service
python tips
JSON formatting
python function ①
Python basics
Python memo
Write JSON Schema in Python DSL
ufo-> python (3)
Python comprehension
install python
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
[Introduction to Python] How to parse JSON
python tips
Installing Python 3.4.3.
Python memo
Python iterative
Dynamically load json type in python
Python algorithm
Handling of JSON files in Python
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial
Python decimals
Python summary
[Python] Sort
JSON encoding and decoding with python
Python basics ③
python log
Validate JSON objects using Python DictShield
[Scraping] Python scraping
Python update (2.6-> 2.7)
python memo
Python memorandum