Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ricardolonga/jsongo
Fluent API to make it easier to create Json objects.
https://github.com/ricardolonga/jsongo
Last synced: 10 days ago
JSON representation
Fluent API to make it easier to create Json objects.
- Host: GitHub
- URL: https://github.com/ricardolonga/jsongo
- Owner: ricardolonga
- License: apache-2.0
- Created: 2015-08-07T23:23:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-10-04T03:26:13.000Z (about 3 years ago)
- Last Synced: 2024-10-25T05:26:00.192Z (11 days ago)
- Language: Go
- Size: 20.5 KB
- Stars: 109
- Watchers: 1
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - jsongo - Fluent API to make it easier to create Json objects. (JSON / Search and Analytic Databases)
- awesome-go - jsongo - Fluent API to make it easier to create Json objects. - ★ 83 (Utilities)
- awesome-go-extra - jsongo - 08-07T23:23:17Z|2021-10-04T03:26:13Z| (JSON / Advanced Console UIs)
README
Jsongo
===================**Fluent API** to make it easier **to create Json** objects.
[![travis-ci](https://travis-ci.org/ricardolonga/jsongo.svg)](https://travis-ci.org/ricardolonga/jsongo)
[![codecov](https://codecov.io/gh/ricardolonga/jsongo/branch/master/graph/badge.svg)](https://codecov.io/gh/ricardolonga/jsongo)
[![goreportcard](https://goreportcard.com/badge/github.com/ricardolonga/jsongo)](http://gocover.io/github.com/ricardolonga/jsongo)Install
-------------
```
go get github.com/ricardolonga/jsongo
```Usage
-------------
To create this:
```
{
"name":"Ricardo Longa",
"idade":28,
"owner":true,
"skills":[
"Golang",
"Android"
]
}
```
Do this:
```
import (
j "github.com/ricardolonga/jsongo"
)json := j.Object().Put("name", "Ricardo Longa").
Put("idade", 28).
Put("owner", true).
Put("skills", j.Array().Put("Golang").
Put("Android"))log.Println(json.Indent())
log.Println(json.String())
```
##### Convert object/array to indented String:
```
json.Indent()
```
##### Convert object/array to String:
```
json.String()
```
##### To remove a field of the object:
```
json.Remove("skills")
```
##### To get a field of the object:
```
json.Get("skills") // Return is interface{}.
```
##### To range over a array:
```
results := Array().Put("Golang").Put("Android").Put("Java")for i, result := range results.Array() {
}
```
##### To get Array size:
```
array := j.Array().Put("Android").
Put("Golang").
Put("Java")
array.Size() // Result is 3.
```Copyright
-------------
Copyright (c) 2015 Ricardo Longa.
Jsongo is licensed under the **Apache License Version 2.0**. See the LICENSE file for more information.