John Kouraklis 94 Posted August 12, 2019 Hi, I am looking for a parser for Relaxed JSON (http://www.relaxedjson.org) Does anyone have and willing to share? Thanks Share this post Link to post
Tommi Prami 130 Posted August 13, 2019 Seems to me that is not very smart format/standard. If some service produce it and have to use it, then for sure need an parser. But I would steer away from that format if just can. Little bit sketchy. -Tee- Share this post Link to post
David Heffernan 2345 Posted August 13, 2019 Yeah, seems pointless. Use YAML if you want more readable files. 1 Share this post Link to post
Lars Fosdal 1792 Posted August 13, 2019 I prefer regular Json as defined by Ecmascript ES5 / https://json.org When exchanging data, I prefer rigid formats over flexible formats. 1 Share this post Link to post
stijnsanders 35 Posted August 13, 2019 I've been dabbling on a JSON parser that accepts pascal strings, and "=" instead of ":", and allows missing ","... https://github.com/stijnsanders/jsonDoc Share this post Link to post
Arnaud Bouchez 407 Posted August 13, 2019 (edited) The mORMot parser supports "extended JSON", as used with MongoDB: field names can be without quotes. It follows in fact the JavaScript object declaration syntax. Internally - between mORMot client and server - it will use it to slightly reduce size and enhance performance. For regular clients (e.g. JavaScript), it will server standard JSON with quoted field names. As @Lars Fosdal states, a rigid format seems better when exchanging data between heterogeneous ends. Edited August 13, 2019 by Arnaud Bouchez 1 Share this post Link to post
Sherlock 663 Posted August 13, 2019 3 hours ago, David Heffernan said: Yeah, seems pointless. Use YAML if you want more readable files. I second that! Share this post Link to post
Guest Posted August 13, 2019 That looks scary. Parsing JSON is already a minefield. Share this post Link to post
John Kouraklis 94 Posted August 13, 2019 It's not scary...it's human readable It's used extensively in the micro services world along with the radix (trie) tree. BTW, anyone knows any implementation of that one? Share this post Link to post
Arnaud Bouchez 407 Posted August 13, 2019 The worse about Relaxed JSON is that it is not reversible. It may change the values. For instance, { number: 1.0 } will become { number: 1 } which is not the same. So for an exchange format, I would never use Relaxed JSON. For a settings local file, edited via vim or nano - why not? but as @David Heffernan stated, YAML (or TOML) sounds like better candidates. Share this post Link to post
David Heffernan 2345 Posted August 13, 2019 I don't think that toml is widely used, although I admire its goals. I also believe that it has some limitations. And I don't think there is a Delphi parser for it. Share this post Link to post
John Kouraklis 94 Posted August 13, 2019 3 hours ago, Arnaud Bouchez said: For instance, { number: 1.0 } will become { number: 1 } which is not the same. Why this? Share this post Link to post
Sherlock 663 Posted August 14, 2019 Off the top of my head: One is an integer the other is a floating point. Share this post Link to post
John Kouraklis 94 Posted August 14, 2019 @Sherlock Ahh...very acute observation My question is why relaxed JSON will interpret 1.0 as 1 as @Arnaud Bouchez says Share this post Link to post
Mahdi Safsafi 225 Posted August 14, 2019 22 hours ago, Arnaud Bouchez said: For instance, { number: 1.0 } will become { number: 1 } which is not the same. Are you sure about that ? Share this post Link to post
Arnaud Bouchez 407 Posted August 16, 2019 From the relaxed JSON website: Quote If a simple-value can be parsed as a number, it will become a JSON number. { number: 1.0} will become { "number" : 1 } I still don't get what a "JSON number" is - from its json.org definition, it is any kind of number with none to any decimals... Share this post Link to post