JSON::Native

JSON::Native

A drop-in for JSON::Fast — replace use JSON::Fast with use JSON::Native and the program keeps working — that takes each engine's fastest exact path. No dependencies.

use JSON::Native;
my $data = from-json('{"a": [1, 2.5, true, null]}');
    say $data<a>[1].WHAT;        # (Rat) — Raku numerics, not doubles
    say to-json($data, :!pretty);
say json-backend;            # which path parses here
    say json-backend(:write);    # and which one writes

Backends

  • Raku++ answers with its own codec (engine). An engine that knows this module answers use JSON::Native itself and never reads this file.

  • Rakudo parses with its own built-in copy of JSON::Fast, Rakudo::Internals::JSON, and writes with JSON::Native::Rakudo, an nqp:: writer that only Rakudo ever loads (rakudo).

  • mutsu uses the JSON::Fast it ships with (json-fast).

  • Everywhere, JSON::Native::Raku — JSON::Fast's behaviour in plain Raku (raku) — answers what the others decline or refuse, and is the whole of the module on any other engine. It is loaded the first time a call needs it.

JSON_NATIVE_BACKEND names one to use instead. One that is not available is reported on STDERR, and the usual choice is used.

JSON::Native v0.1.0

JSON parsing and writing, a drop-in for JSON::Fast that takes each engine's fastest path — Raku++'s built-in codec, Rakudo's own — with pure Raku everywhere else

Authors

  • Andrew Shitov

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • JSON::Native
  • JSON::Native::Raku
  • JSON::Native::Rakudo

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.