Loading ...
Sorry, an error occurred while loading the content.

Re: [json] Do numeric values need to be double quoted when returned in objects?

Expand Messages
  • John Cowan
    ... So it should: strings are quoted, numbers are not. ... Right. -- John Cowan cowan@ccil.org http://ccil.org/~cowan In computer science, we stand on each
    Message 1 of 4 , Mar 11, 2011
    • 0 Attachment
      toddkingham scripsit:
      > Just as the subject suggests... Do you need to double quote numeric
      > values to be valid JSON? JSONlint seems to validate the following
      > string just fine: {"age":35}

      So it should: strings are quoted, numbers are not.

      > I believe the part in the spec that says all STRINGS must be double
      > quoted doesn't apply to numeric values as they are not strings...yes?

      Right.

      --
      John Cowan cowan@... http://ccil.org/~cowan
      In computer science, we stand on each other's feet.
      --Brian K. Reid
    • toddkingham
      Thanks.... that was fast :)
      Message 2 of 4 , Mar 11, 2011
      • 0 Attachment
        Thanks.... that was fast :)

        --- In json@yahoogroups.com, John Cowan <cowan@...> wrote:
        >
        > toddkingham scripsit:
        > > Just as the subject suggests... Do you need to double quote numeric
        > > values to be valid JSON? JSONlint seems to validate the following
        > > string just fine: {"age":35}
        >
        > So it should: strings are quoted, numbers are not.
        >
        > > I believe the part in the spec that says all STRINGS must be double
        > > quoted doesn't apply to numeric values as they are not strings...yes?
        >
        > Right.
        >
        > --
        > John Cowan cowan@... http://ccil.org/~cowan
        > In computer science, we stand on each other's feet.
        > --Brian K. Reid
        >
      • jonathan wallace
        { age :35} { age : 35 } Are both legal JSON, but very different objects.  In the first, age is the number 35, the second is a string with characters 3 and
        Message 3 of 4 , Mar 11, 2011
        • 0 Attachment
          {"age":35}

          {"age":"35"}

          Are both legal JSON, but very different objects.  In the first, age is the number 35, the second is a string with characters '3' and '5'.
           
          "People have always been impressed by the power of our example, not the example of our power." - William Jefferson Clinton


          ________________________________
          From: toddkingham <toddkingham@...>
          To: json@yahoogroups.com
          Sent: Friday, March 11, 2011 5:16 PM
          Subject: [json] Do numeric values need to be double quoted when returned in objects?


           
          Just as the subject suggests... Do you need to double quote numeric values to be valid JSON? JSONlint seems to validate the following string just fine: {"age":35}

          I believe the part in the spec that says all STRINGS must be double quoted doesn't apply to numeric values as they are not strings...yes?

          Thanks







          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.