Skip to content

LittleJianCH/IoJSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

IoJSON

This a json library for IoLanguage.

Installation

First, you should clone the repository in your project directory.

git submodule add https://github.com/LittleJianCH/IoJSON

Then you can use IoJSON in your project by doFile

doFile(the_path_to_json_io) 
// e.g. doFile("./IoJSON/json.io")

Usage

There're two ways to use read a json file.

json1 := JSON clone readFromFile("./example.json")

json2 := JSON clone readFromString("{\"name\":\"littlejian\",\"age\":18, \"hobbies\":[\"code\",\"play\",\"drink\"]}")

As JSON is inherited from Map, you can use it like a Map.

json2 at("name") println

json2 at("hobbies") foreach(hobby, 
  hobby println
) 

json2 foreach(key, value, 
  key println
  value println
)

json2 atPut("height", 180)

You can also use stringfy to convert a JSON to a String.

json2 stringfy println

Something more

If you want to know more about IoJSON, here's a blog about it: https://littlejianch.github.io/let-s-implment-a-json-lib-in-io-by-metaprogramming/

About

A JSON library implemented by metaprogramming in Io

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages