diff --git a/playground/json/test.json b/playground/json/test.json new file mode 100644 index 00000000..778faebe --- /dev/null +++ b/playground/json/test.json @@ -0,0 +1,9 @@ +{ + "array": [1, 2, "abc", 4.8, null], + "dict": { + "integer": 1, + "float": 4.8, + "string": "Hello, world!" + }, + "boolean": true +} diff --git a/playground/json/wscript b/playground/json/wscript new file mode 100644 index 00000000..48f819b4 --- /dev/null +++ b/playground/json/wscript @@ -0,0 +1,32 @@ +#! /usr/bin/env python +# encoding: utf-8 +# Matt Clarkson, 2015 (ita) + +VERSION='0.0.1' +APPNAME='json_test' + +top = '.' + +import sys +import waflib.Configure +waflib.Configure.autoconfig = True + +def options(opt): + opt.add_option( + '--pretty', + action = 'store_true', + help = 'pretty prints the writing of the JSON') + +def configure(conf): + pass + +def build(bld): + node = bld.srcnode.make_node('test.json') + json = node.read_json() + print('Read', json) + json['new_key'] = { + 'number': 199 + } + output = bld.bldnode.make_node('output.json') + output.write_json(json, pretty=bld.options.pretty) + print('Wrote', output.read())