Skip to content

Instantly share code, notes, and snippets.

@bradym
Last active February 13, 2018 23:02
Show Gist options
  • Save bradym/04a76bad170db45365604d52c0706ff8 to your computer and use it in GitHub Desktop.
Save bradym/04a76bad170db45365604d52c0706ff8 to your computer and use it in GitHub Desktop.
JSON encode question

Most modern languages include a library for dealing with json, including converting a native object to a json string.

In the language of your choice, write a function to convert a native object to a json string.

A python example is provided below.

import json
sample_object = {
'name': 'BloomBoard',
'colors': ['red','blue','orange'],
'number': 42
}
print(json.dumps(sample_object))
{"colors": ["red", "blue", "orange"], "name": "BloomBoard", "number": 42}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment