0xCODE
Published in

0xCODE

Extracting data from JSON using Python.

Simple Data Serialization And Extraction From JSON Using Python

{
"address": "
vince0x@code.com",
"username": "vince0x",
"domain": "code.com",
"suggestion": "",
"validFormat": true,
"deliverable": true,
"fullInbox": false,
"hostExists": true,
"catchAll": false,
"gravatar": false,
"role": false,
"disposable": false,
"free": false
}
>>> dir(json)['JSONDecodeError', 'JSONDecoder', 'JSONEncoder', '__all__', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_default_decoder', '_default_encoder', 'codecs', 'decoder', 'detect_encoding', 'dump', 'dumps', 'encoder', 'load', 'loads', 'scanner']
import jsonwith open('data.json') as json_file:
data = json.load(json_file)
b = json.dumps(data)
print(b)
{"address": "vince0x@code.com", "username": "vince0x", "domain": "code.com", "suggestion": "", "validFormat": true, "deliverable": true, "fullInbox": false, "hostExists": true, "catchAll": false, "gravatar": false, "role": false, "disposable": false, "free": false}
import jsonwith open('data.json') as json_file:
data = json.load(json_file)
print('"address":', data['address'])
import jsonwith open('data.json') as json_file:
data = json.load(json_file)
print('"validFormat":', data['validFormat'])

--

--

Essays and Articles on software engineering, development and computer science.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Tabora

Editor HD-PRO, DevOps, Cybersecurity, Blockchain, Software Development, Engineering, Photography, Technology