[erlang-questions] javascript . notation to fetch objects from JSON decode_string/1

Richard A. O'Keefe ok@REDACTED
Wed Aug 20 07:13:34 CEST 2008


On 19 Aug 2008, at 7:15 pm, Bharani wrote:

>
> Pattern matching is OK if you have a small string.

Actually, that's not the main issue.
The thing that makes pattern matching less useful with JSON terms
is that
  - there may be more "fields" in an "object" than you were expecting
  - the order in which the "fields" of an "object" are returned may
    not be predictable.

>  Then again
> JSON is for javascript and not Erlang - i am just trying to find out  
> the
> best approach.

I am currently trying to learn AppleScript.
I was enchanted to discover that it uses
	{1, 2, 3, 4}
for a "list" of 4 numbers, and
	{foo: 1, ping: 2, whatever: 3, stuff: 4}
for a "record".  Modulo the brackets, JSON makes sense for
AppleScript too.

What we *really* want to turn JSON "objects" into is what I've
called "frames" = what Joe Armstrong called "proper structs",
and for those, pattern matching *would* work.

Of course large patterns are no more readable than large anythings.




More information about the erlang-questions mailing list