# How to use JSON in Raku

**URL:** <https://forum.codeselfstudy.com/t/how-to-use-json-in-raku/2519>\
**Category:** Tutorials\
**Tags:** raku\
**Created:** [November 25, 2020, 9:05am UTC](https://forum.codeselfstudy.com/t/how-to-use-json-in-raku/2519 "2020-11-25T09:05:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh](https://forum.codeselfstudy.com/user_avatar/forum.codeselfstudy.com/josh/32/4_2.png) [@Josh](https://forum.codeselfstudy.com/u/Josh)\
**Post date:** [November 25, 2020, 9:05am UTC](https://forum.codeselfstudy.com/t/how-to-use-json-in-raku/2519/1 "2020-11-25T09:05:34Z")

</div>

Google’s search results are missing an easy to find quickstart on how to deal with JSON in Raku (Perl 6), so I thought I would write a page for it.

First, install `JSON::Tiny` with the package manager:

```auto
$ zef install JSON::Tiny

```

Then in your script:

```nohighlight
use JSON::Tiny;

say to-json({hello => 'world'});
# output: { "hello" : "world" }

say from-json('{"hello":"world"}');
# output: {hello => world}

```

To use it in a one-liner, load the module with `-M` first and use `-ne`:

```nohighlight
$ curl -s http://api.open-notify.org/iss-now.json | \
    raku -MJSON::Tiny -ne 'say from-json($_)<iss_position>'

```

It’s probably simpler to use [`jq`](https://stedolan.github.io/jq/) for a one-liner like that, but I wanted to at least learn how to get it to run with Raku. Here’s the `jq` version:

```nohighlight
$ curl -s http://api.open-notify.org/iss-now.json | jq ".iss_position"

```

I hope this post saves someone 15 minutes. 🙂

Docs:

> **[Raku Modules
      Directory](https://modules.raku.org/dist/JSON::Tiny:cpan:MORITZ)**

Related: [How to make HTTP requests in Raku (Perl 6)](https://forum.codeselfstudy.com/t/how-to-make-http-requests-in-raku-perl-6/2518)
