Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Basic JSON question: Do I really need the quotes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
moo...@yahoo.co.uk  
View profile  
 More options Oct 12 2012, 10:09 am
Newsgroups: comp.lang.python
From: moo...@yahoo.co.uk
Date: Fri, 12 Oct 2012 07:09:08 -0700 (PDT)
Local: Fri, Oct 12 2012 10:09 am
Subject: Basic JSON question: Do I really need the quotes
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kwpolska  
View profile  
 More options Oct 12 2012, 10:14 am
Newsgroups: comp.lang.python
From: Kwpolska <kwpol...@gmail.com>
Date: Fri, 12 Oct 2012 16:14:35 +0200
Local: Fri, Oct 12 2012 10:14 am
Subject: 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roel Schroeven  
View profile  
 More options Oct 12 2012, 1:27 pm
Newsgroups: comp.lang.python
From: Roel Schroeven <r...@roelschroeven.net>
Date: Fri, 12 Oct 2012 19:27:05 +0200
Local: Fri, Oct 12 2012 1:27 pm
Subject: 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Tauno Williams  
View profile  
 More options Oct 12 2012, 1:52 pm
Newsgroups: comp.lang.python
From: Adam Tauno Williams <awill...@whitemice.org>
Date: Fri, 12 Oct 2012 13:52:42 -0400
Local: Fri, Oct 12 2012 1:52 pm
Subject: 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.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roy Smith  
View profile  
 More options Oct 12 2012, 8:03 pm
Newsgroups: comp.lang.python
From: Roy Smith <r...@panix.com>
Date: Fri, 12 Oct 2012 20:03:44 -0400
Local: Fri, Oct 12 2012 8:03 pm
Subject: Re: Basic JSON question: Do I really need the quotes
In article <cbd2f125-38ca-4f46-9077-95de0cf7ea6f@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" :-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rusi  
View profile  
 More options Oct 12 2012, 11:30 pm
Newsgroups: comp.lang.python
From: rusi <rustompm...@gmail.com>
Date: Fri, 12 Oct 2012 20:30:47 -0700 (PDT)
Local: Fri, Oct 12 2012 11:30 pm
Subject: 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-95de0cf7ea6f@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'


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
moo...@yahoo.co.uk  
View profile  
 More options Oct 15 2012, 1:48 am
Newsgroups: comp.lang.python
From: moo...@yahoo.co.uk
Date: Sun, 14 Oct 2012 22:48:54 -0700 (PDT)
Local: Mon, Oct 15 2012 1:48 am
Subject: Re: Basic JSON question: Do I really need the quotes

Hi,
Thanks to everyone for the responses. I'll look at YAML and ConfigParser.
Steven

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »