Ok, I just added a first cut JSON system in web/json.flx.
This is a basic data structure, parser, and pretty printer.

Bugs:  

* Only accepts integers (no floats yet).
* Only accepts strings without weird quotation stuff
* Accepts any C identifier starting with alpha as a name,
  instead of just null, true, false

* The representation is poor: both arrays and dictionaries are just lists.
*  Integers are also just strings

* The pair type will accept any Jvalue, not just a string. However the parser
only parses strings.

The float bug will be fixed, as will the string thing.

The plan: for dictionaries, non-string values will be allowed.
When output is done, the Felix repr of the value will be used as a key.
The converse could be made to happen too. It's not clear why Json
bothered putting this constraint in the language. It is clear why many
representations of dictionaries only accept keys which are strings.

Names:  There are two uses of other names. One is just an extension.
The other is more interesting. We would like to allow a json variable
in a data structure so you can make definitions. Perhaps this should
have a unique syntax:

var x =  '{"a":1}';
var y = '[2, x]';

so y == [2, {a:1}]

Perhaps .. 

var y = q'[2, $(x)]';

because that's the existing (just added!) way to do interpolation.
Or something! Regdefs allow this. However that's syntax:

var y = json ( [2, x] );

This is using the Json parser, the x here is a real symbol that can be bound
to a real Felix variable x.

Another dynamic way is:

        bind ('[2,x]',  '{"x": {"a":1}}')

This takes expression 1, and replaces x with its value in the dictionary of 
argument 2,
this is completely dynamic. YMMV.

BTW: I need Json now, because I want to use it as a configuration language
for the process manager tools/launch.flx, which is meant to test the 0MQ Guide
examples and do other things.


--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to