2

I'm confused what free-form JSON means. Does it mean you can put any types as values in {}?

I thought all JSON are like that (i.e. {'hi':123, 'abc':{'d':[1,2,3],'e':'yay'}}).

So what does free-form JSON mean. Is this a redundant term? Is there such thing as non-free-form JSON?

Popcorn
  • 5,188
  • 12
  • 54
  • 87
  • 2
    It would help if you could provide the context in which you saw the phrase "freeform JSON." It's possible that no distinction exists and the word was just being used for emphasis (e.g. to contrast with XML and other highly structured formats). – Kevin Sep 19 '15 at 22:57
  • 1
    [Eclipse Bug 407498 - Exception unmarshalling freeform JSON object containing JSON array](https://bugs.eclipse.org/bugs/show_bug.cgi?id=407498) suggests that "freeform" implies one or more parts of an object may change whereas "non-freeform" means no part of an object changes (all "fields" remain present and can be accessed). [How to allow free-form JSON data within Mongoose documents?](http://stackoverflow.com/q/10403450/539810) also seems to suggest the same thing. –  Sep 20 '15 at 00:07

1 Answers1

1

What you have just posted looks like a JavaScript object, but it is not valid JSON. JSON has some very strict rules, such as all strings must be in double quotes. See JSON.org

There's no such thing as "free-form"/"non-free-form" JSON as every valid JSON-string must be formatted according to the specific rules mentioned on JSON.org.

It's possible that "free-form" JSON is JSON that has been generated "by hand" meaning that you typed it out manually (error prone). Most languages either have built-in methods, or libraries that are available, that turn native data structures (like multi-dimensional arrays) into valid JSON.

PHP, for instance, has a native method called json_encode.

Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100