0

Consider I have following typed JSON objects:

Parent: {
    "field1" : "Value of field1"
    "fieldC" : {Child}
}

Child: {
    "field2" : "Value of field2"
}

Q: What do I call field1 and field2?
Just Strings?
Q: What to i call the "path" fieldC.field2?
Accessor path?
Field path?
Member hierarcy path?

straville
  • 986
  • 3
  • 15
  • 21
  • 1
    are you asking about properties? – Sujit.Warrier Sep 02 '16 at 06:14
  • Maybe "property" and "object-hierarchical property path" are the answers I'm looking for. However json.org does not mention 'property', although it would make sense as JSON is "based on a subset of JS". They just call the 'fields' i'm referring to as 'names' (of a 'name/value' pair). – straville Sep 05 '16 at 13:10

2 Answers2

1

field1 and field2 are just strings.

[anything, ..., ... ] is just an array, so the elements of an object.

and then you have 0-9 (with decimals, negative, positive or with e), true/false and null, as numeric values, boolean and nullvalue

{Child} is an object. I don't think it's called path (I'd say that's opinion-based). maybe field-path, but it's rather a child-object. the key is a string and the value is an object/array/string/bool/null/numeric or decimal

all the possibilities e.g.:

{
    "string": "string-value",
    "nulltype": null,
    "child_object": {
        "boolean": true,
        "any_decimal_int": -1.5e3
    },
    "array_values":[
        {
            "any_value": true
        },
        {
            "any_value": false
        }
    ]
}

of course you can combine more and have unlimited child-objects and lists :)

Matthias Burger
  • 5,549
  • 7
  • 49
  • 94
  • Thanks! I'm aware of the key:value / name:value / string:value nature of JSON. I'm just looking for the correct way to call the "keys" (and their hierarchical path in case objects have have child objects), according to a specification preferably. You have a point tough, according to the spec, the "path" probably has no name. However I would like to have a name for the practice of "writing open" "property paths" such as fieldC.field2. Going with "property path" if something else is not proven correct : ] – straville Sep 05 '16 at 13:16
1

jsonapi.org seems to refer field1,fieldC,and field2 as member names, which I find much more descriptive than just 'Strings'.

As mentioned in my comment to first answer, I guess I'll personally be using (hierarchical) property path or just (object) member hierarchy while referring to 'writing open' the object-hierarchical property/attribute/member 'path' such as fieldC.field2. Seems to be alot of room for interpretation in that. : ]

straville
  • 986
  • 3
  • 15
  • 21