juan_gandhi: (Default)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2010-02-16 06:33 pm

formulas as json

Tell me friends, is there a reasonable way to represent formulas (like logical conditions, for instance) in json format? Kind of... not obvious to me.

[identity profile] cema.livejournal.com 2010-02-17 02:35 am (UTC)(link)
Only as functions, I think.

[identity profile] ygam.livejournal.com 2010-02-17 03:31 am (UTC)(link)
{op:ge arg1:{op:plus arg1:1 arg2:{op:minus arg1:2 arg2:3}} arg2:0}

[identity profile] exceeder.livejournal.com 2010-02-17 05:22 am (UTC)(link)
Why not pass it as a string? In JavaScript there is eval(). If JSON is just a transport, for sure there is a library to evaluate it in any language you are using.

Unless, of course, the formulas are real huge and have to be pulled in in pieces depending on calculation context. Hard to imagine these days. Whoever owns the full formula should to the folding anyways.