Giter Club home page Giter Club logo

cheetah's Introduction

Cheetah

A simple, yet fast JSON library. Developed for the OpenKitten ecosystem, it is created to feel like it belongs to the ecosystem as well as the programming language.

Cheetah's aim is to be a performant parser/serializer and to provide a good API.

Usage

Import this dependency into your Package.swift

.Package(url: "https://github.com/OpenKitten/Cheetah.git", majorVersion: 1)

Deserialize from UTF-8 bytes representing a JSON String:

let array = JSONArray(from: bytes)
let object = JSONObject(from: bytes)

Deserialize from a Swift String JSON:

let array = JSONArray(from: bytes)
let object = JSONObject(from: bytes)

Access values in an array like you would in Swift Arrays and values in an object like a Dictionary.

let favouriteNumber = favouriteNumbers[0]
let usernameValue = userObject["username"]

Extract types with simplicity:

let username = String(userObject["username"]) // "Joannis"
let isOnline = Bool(userObject["online"]) // true
let age = Int(userObject["age"]) // 20
let pi = Double(userObject["pi_constant"]) // 3.14

Chain subscripts easily to find results without a hassle as shown underneath:

{
  "users": [
  	{
  		"username": "Joannis",
  		"profile": {
  		  "firstName": "Joannis",
  		  "lastName": "Orlandos"
  		}
  	},
  	{
  		"username": "Obbut",
  		"profile": {
  		  "firstName": "Robbert",
  		  "lastName": "Brandsma"
  		}
  	}
  ]
}
let obbutLastName = String(object["users"][1]["profile"]["lastName"]) // "Brandsma"

Tutorials/info

Tutorials and docs are available among the rest.

cheetah's People

Contributors

joannis avatar obbut avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.