Giter VIP home page Giter VIP logo

rjson's Introduction

RJSON

Build Status GoDoc Go Report Card Software License

Package rjson implements a backwardly compatible version of JSON with the aim of making it easier for humans to read and write.

The data model is exactly that of JSON's and this package implements all the marshalling and unmarshalling operations supported by the standard library's json package.

The three principal differences are:

- Quotes may be omitted for some object key values (see below).
- Commas are automatically inserted when a newline is encountered after a value (but not an object key).
- Commas are optional at the end of an array or object.

The quotes around an object key may be omitted if the key matches the following regular expression:

[a-zA-Z][a-zA-Z0-9\-_]*

This rule will be relaxed in the future to allow unicode characters, probably following the same rules as Go's identifiers, and probably a few more non-alphabetical characters.

Installation

$ go get github.com/mantyr/rjson

Example

package main

import (
    "fmt"
    "github.com/mantyr/rjson"
)

func main() {
    data := []byte(`{
        middle : {
            src: "pictures/product/123.jpg",
            place : '#preview-img',                // Added support for JavaScript object parsing
            title: "title"
        }
    }`)

    var v struct {
        Middle struct {
            Src string
            Place string
            Title string
        }
    }
    err := rjson.Unmarshal(data, &v)
    fmt.Println(v)   // print {{pictures/product/123.jpg #preview-img title}}
    fmt.Println(err) // print <nil>
}

Author

Roger Peppe [email protected]

rjson's People

Contributors

rogpeppe avatar

Watchers

James Cloos avatar Oleg Shevelev avatar  avatar

Forkers

caringcompany

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.