Skip to content

Instantly share code, notes, and snippets.

@LouisdeBruijn
Created December 31, 2020 11:06
Show Gist options
  • Select an option

  • Save LouisdeBruijn/e9784e84f9c43276e4b4db96e69585e7 to your computer and use it in GitHub Desktop.

Select an option

Save LouisdeBruijn/e9784e84f9c43276e4b4db96e69585e7 to your computer and use it in GitHub Desktop.
import json
# JSON encoding
string = "I am a data-scientist and love working with Natural Language Processing."
s = json.dumps(string)
with open("data.json", "w") as json_out:
json.dump(string)
# JSON decoding
string = '["list_item", {"personal":["Louis", null, 8.3, 26]}]'
s = json.loads(string)
with open("data.json", "r") as json_in:
string = json.load(json_in)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment