DEV Community

Dat One Dev
Dat One Dev

Posted on

JSON in Miniscript

Introduction

Hey fellas
Today we are going to use the powerful and almighty JSON in Miniscript.

But hold up... I can already hear some of you saying:

“Wait, what even is JSON?”

No worries — I’ve got you covered!

I already wrote a separate post just for that topic (told you, I’m always two steps ahead 😎):

👉What is JSON?

What is JSON.

But just to save you some seconds , here’s a quick summary right here:

JSON stands for JavaScript Oriented Notation it is a lightweight data-interchange format which is easy for humans to read and study.

Hope that's enough summary if you need more you can checkout the post I mentioned earlier

So lets get started how to use JSON in Miniscript

How to Use JSON in MiniScript.

MiniScript has a dedicated JSON library just for handling JSON data.

It even has very special name and it is......... JSON (Be simple Be positive).

Where to Find It

To see inside the JSON library, just do this in Mini Micro:

cd "/sys/lib"
load "json.ms"
edit
Enter fullscreen mode Exit fullscreen mode

You’ll be staring at a 394-line-long code.
(Shoutout to the devs who made this so clean and readable.)

But hey..
Learning by reading 394 lines? That's what I say learn by coding

Here is more learn by coding
👉Learn By Code 1.1
👉Learn By Code 1.2

How to import libraries

Just before ending the blog in order to import a library you need to use this command.

import "json"
Enter fullscreen mode Exit fullscreen mode

This imports the JSON library into your program.

Now… what can this library do?

At its core, it helps you:

  • Convert MiniScript values to JSON
  • Parse JSON strings into MiniScript values

If you're saving game progress, loading level data, or just messing with structured data—this library can be very helpfull.

Outro

That's it for todays blog.

Stay curios stay selfish.

Top comments (0)