1097b14a7f
* Migrations in place, how to run them? * Remove down migrations and touch database.go * Database and Database Test package in place, added functions to get and store app metrics * make generate output * Minor bug fix on app metrics insert and select * Add a validation layer to restrict what can be saved in the database * Make validation more terse, throw error if schema doesn't exist, expose appmetrics service * service updates * Compute all errors before sending them out * Trying to bring a closjure to appmetrics go * Expose appmetrics via an api, skip fancy * Address value as Jason Dawt Rawmasage to ease parsing * Introduce a buffered chan with magic cap of 8 to minimize writes to DB. Tests for service and API. Also expose GetAppMetrics function. * Lint issues * Remove autoincrement, undo waku.json changes, fix error being shadowed, return nil where nil ought to be returned, get rid of buffered channel * Bump migration number * Fix API factory usage * Add comment re:json.RawMessage instead of strings * Get rid of test vars, throw save error inside the loop * Update version Co-authored-by: Samuel Hawksby-Robinson <samuel@samyoul.com> |
||
---|---|---|
.. | ||
LICENSE-APACHE-2.0.txt | ||
README.md | ||
pointer.go |
README.md
gojsonpointer
An implementation of JSON Pointer - Go language
Usage
jsonText := `{
"name": "Bobby B",
"occupation": {
"title" : "King",
"years" : 15,
"heir" : "Joffrey B"
}
}`
var jsonDocument map[string]interface{}
json.Unmarshal([]byte(jsonText), &jsonDocument)
//create a JSON pointer
pointerString := "/occupation/title"
pointer, _ := NewJsonPointer(pointerString)
//SET a new value for the "title" in the document
pointer.Set(jsonDocument, "Supreme Leader of Westeros")
//GET the new "title" from the document
title, _, _ := pointer.Get(jsonDocument)
fmt.Println(title) //outputs "Supreme Leader of Westeros"
//DELETE the "heir" from the document
deletePointer := NewJsonPointer("/occupation/heir")
deletePointer.Delete(jsonDocument)
b, _ := json.Marshal(jsonDocument)
fmt.Println(string(b))
//outputs `{"name":"Bobby B","occupation":{"title":"Supreme Leader of Westeros","years":15}}`
References
http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07
Note
The 4.Evaluation part of the previous reference, starting with 'If the currently referenced value is a JSON array, the reference token MUST contain either...' is not implemented.