libmir / asdf

JSON library
http://asdf.libmir.org
Boost Software License 1.0
20 stars 8 forks source link

asdf has compatible JSONValue? #3

Closed zoujiaqing closed 3 years ago

zoujiaqing commented 4 years ago
#include "simdjson.h"

int main(void) {
  simdjson::dom::parser parser;
  simdjson::dom::element tweets = parser.load("twitter.json");
  std::cout << tweets["search_metadata"]["count"] << " results." << std::endl;
}

So asdf code:

tweets["search_metadata", "count"];

JSONValue code:

tweets["search_metadata"]["count"].get!uint;
9il commented 4 years ago

Could you please clarify what means compatible?

9il commented 4 years ago

ASDF doesn't use Phobos JSONValue.

zoujiaqing commented 4 years ago

I meanns use more common ways of using..

9il commented 4 years ago

Like this one?

import std.conv: to;
auto integer = tweets["search_metadata", "count"].to!int;
zoujiaqing commented 4 years ago

Like this one:

tweets["search_metadata"]["count"];
9il commented 4 years ago

Maybe Asdf type is what you are looking for.

9il commented 4 years ago

If you are asking about if Asdf is compatible with JSONValue. No, it isn't.

9il commented 3 years ago

Asdf can now be de/serialized to/from mir.algebraic types.

https://forum.dlang.org/thread/itdobhbjiynjtijschoe@forum.dlang.org