And if we really want to split hairs, JSON isn't a string. It's text.
A string is a specific JavaScript object type with its own associated
methods, which have no meaning in other languages. JSON is a text
format that is completely language independent (and JSON was
specifically designed as a data-interchange format).

What your JSON becomes depends upon who you treat the response;
conventionally it is eval'd and so at that point it is JavaScript.

It's not unconventional however to still refer to JSON that has been
received in an ajax response and eval'd as... JSON or JSON data, or
your 'data object' etc. It's also conventional (and correct) to refer
to the specific eval'd response that the OP gave (see below) as an
object, because that's what it is :)

{
        "product_id":"000003",
        "product_name":"Sample shoe",
        "product_brand":"Shoe Brand",
        "product_slug":"slug3",
        "product_description":"description3",
        "product_active":"1",
        "product_type":"shoe",
        "product_gender":"youth",
        "product_sizes":"14",
        "product_style":"style 3",
        "product_categories":"3",
        "product_shipping":"shipping 3",
        "product_cost":"40.0",
        "product_retail":"70.0"
}



On Apr 16, 5:14 pm, mkmanning <michaell...@gmail.com> wrote:
> As I said before: it's a string until it's eval'd, which happens with
> the 'json' response type within jQuery, or as I said you can eval the
> response text yourself. At that point it is JavaScript, and it's an
> object whose members you can access with dot or bracket notation and
> that you can iterate over. The OP was indicating that he needed to
> remove the quotes
> "there are quotes on the object side of the json
> where there should be no quotes"
>
> There is no 'object side', there are just name-value pairs within the
> object. The names are strings, strings should be quoted according to
> the RFC which was written by Doug Crockford. As I indicated, you can
> leave the quotes or remove them, as you choose, but was trying to make
> it clear to the OP that that was not where the problem was occuring
> (and correct bad terminology such as 'object side' in much the same
> way Garrett pointed out there's no such thing as "String Brackets").
>
> On Apr 16, 4:28 pm, "Michael Geary" <m...@mg.to> wrote:
>
> > Ah, the O in JSON does stand for Object, but what does the *N* stand for?
> > :-)
>
> > Notation.
>
> > JSON is a string format: It's a *notation* in the form of a string. This
> > string can represent an object or other data type, but JSON is not the
> > object itself.
>
> > The example JSON that the OP posted is evidence of this. It's clearly a
> > string, because that's the only thing you can put in a text email.
>
> > Does that make sense?
>
> > I didn't follow this discussion, so I'm probably missing the context of this
> > mini-controversy. I'm just addressing the specific question of whether JSON
> > is an actual object or a string that represents an object.
>
> > -Mike
>
> > > From: mkmanning
>
> > > So you're saying JSON is not an object, it's a string? What
> > > does the O stand for then? The OP gave this example JSON:
>
> > > {
> > >         "product_id":"000003",
> > >         "product_name":"Sample shoe",
> > >         "product_brand":"Shoe Brand",
> > >         "product_slug":"slug3",
> > >         "product_description":"description3",
> > >         "product_active":"1",
> > >         "product_type":"shoe",
> > >         "product_gender":"youth",
> > >         "product_sizes":"14",
> > >         "product_style":"style 3",
> > >         "product_categories":"3",
> > >         "product_shipping":"shipping 3",
> > >         "product_cost":"40.0",
> > >         "product_retail":"70.0"
> > > }
>
> > > In an ajax response with the reponse type as 'json' (or text
> > > and eval'd yourself if you like), that's an object. It's
> > > composed of name:value pairs. The names are strings. If you
> > > don't like what the RFC says, take it up with Douglas Crockford.
>
> > > On Apr 16, 2:25 pm, dhtml <dhtmlkitc...@gmail.com> wrote:
> > > > On Apr 16, 12:42 am, mkmanning <michaell...@gmail.com> wrote:
>
> > > > > Just an FYI, but there's no 'object side' of the json in
> > > your example.
> > > > > It just an object, consisting of name-value pairs. While you can
> > > > > leave
>
> > > > No, it is not an object. It is a string.
>
> > > > > quotes off of the names, they are strings which, according to the
> > > > > RFC, should be quoted. Doing so will not cause problems, and will
> > > > > save you from potentially running into a situation where
> > > your name
> > > > > conflicts with one of the excessive number of reserved words.
>
> > > > > On Apr 15, 7:05 pm, sneaks <deroacheee...@gmail.com> wrote:
>
> > > > > > the way i see it, there are quotes on the object side
> > > of the json
> > > > > > where there should be no quotes...
>
> > > > That makes about as much sense as something the OP would post.
>
> > > > Garrett

Reply via email to