Re: Basic JSON question: Do I really need the quotes
On Friday, 12 October 2012 16:09:14 UTC+2, (unknown) wrote: Hi, I need to define some configuration in a file that will be manually created. Internally, the data will be stored as a dict, which contains various properties related to a design e.g. Design Name, dependencies, lists of files (and associated libraries). json seemed a quick an easy way of achieving this Anyway, in simple terms my question - if I know everything is a string, how can I omit the quotation marks? i.e. I can do json.loads('{mykey:[data0, data1]}') {u'mykey': [u'data0', u'data1']} But I would like to do json.loads('{mykey:[data0, data1]}') Traceback (most recent call last): The problem is that I don't want to make users have to type redundant characters. Is it possible? Thanks, Steven Hi, Thanks to everyone for the responses. I'll look at YAML and ConfigParser. Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic JSON question: Do I really need the quotes
On Fri, Oct 12, 2012 at 4:09 PM, moo...@yahoo.co.uk wrote: Hi, I need to define some configuration in a file that will be manually created. Internally, the data will be stored as a dict, which contains various properties related to a design e.g. Design Name, dependencies, lists of files (and associated libraries). json seemed a quick an easy way of achieving this Anyway, in simple terms my question - if I know everything is a string, how can I omit the quotation marks? Nope. JSON has those rules for a reason. You need to be specific. A more “human-friendly” format is the one used by ConfigParser (close to INI, but not quite). Also, JSON is supposed to be generated by computers, not humans. -- Kwpolska http://kwpolska.tk stop html mail | always bottom-post www.asciiribbon.org | www.netmeister.org/news/learn2quote.html GPG KEY: 5EAAEA16 -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic JSON question: Do I really need the quotes
moo...@yahoo.co.uk schreef: Hi, I need to define some configuration in a file that will be manually created. Internally, the data will be stored as a dict, which contains various properties related to a design e.g. Design Name, dependencies, lists of files (and associated libraries). json seemed a quick an easy way of achieving this Anyway, in simple terms my question - if I know everything is a string, how can I omit the quotation marks? The problem is that I don't want to make users have to type redundant characters. Is it possible? Not in JSON. Maybe you could try YAML? -- Too often we hold fast to the cliches of our forebears. We subject all facts to a prefabricated set of interpretations. Too often we enjoy the comfort of opinion without the discomfort of thought. -- John F Kennedy r...@roelschroeven.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic JSON question: Do I really need the quotes
On Fri, 2012-10-12 at 19:27 +0200, Roel Schroeven wrote: moo...@yahoo.co.uk schreef: Hi, I need to define some configuration in a file that will be manually created. Internally, the data will be stored as a dict, which contains various properties related to a design e.g. Design Name, dependencies, lists of files (and associated libraries). json seemed a quick an easy way of achieving this Ayway, in simple terms my question - if I know everything is a string, how can I omit the quotation marks? The problem is that I don't want to make users have to type redundant characters. Is it possible? Not in JSON. Maybe you could try YAML? If you want a human-readable human-editable markup for data structures I strongly encourage you to look at YAML. JSON is not wetware friendly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic JSON question: Do I really need the quotes
In article cbd2f125-38ca-4f46-9077-95de0cf7e...@googlegroups.com, moo...@yahoo.co.uk wrote: I need to define some configuration in a file that will be manually created. [...] json seemed a quick an easy way of achieving this JSON would not be my first choice for a file which needs to be maintained by hand. I've only recently started using a system that has YAML config files. I've quickly become enamored of the format for config files. I don't know if it's capable of expressing everything you can with JSON, but it certainly can do anything you would reasonably want to put in a config file, it's easy to read, and easy to hand-edit. The problem is that I don't want to make users have to type redundant characters. I think what you're saying is, My users would prefer YAML over JSON :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Basic JSON question: Do I really need the quotes
On Oct 13, 5:03 am, Roy Smith r...@panix.com wrote: In article cbd2f125-38ca-4f46-9077-95de0cf7e...@googlegroups.com, moo...@yahoo.co.uk wrote: I need to define some configuration in a file that will be manually created. [...] json seemed a quick an easy way of achieving this JSON would not be my first choice for a file which needs to be maintained by hand. I've only recently started using a system that has YAML config files. I've quickly become enamored of the format for config files. I don't know if it's capable of expressing everything you can with JSON, but it certainly can do anything you would reasonably want to put in a config file, it's easy to read, and easy to hand-edit. Yaml is a superset of json http://en.wikipedia.org/wiki/YAML#JSON I find it a bit mysterious: yaml's structure-via-indentation philosophy makes it more in line with python than most other modern languages. And yet its the ruby community that seems to most eagerly embrace yaml. Specially ironic given that ruby's syntax is reminiscent of Pascal -- statements dont just close with '}' but with 'end' -- http://mail.python.org/mailman/listinfo/python-list