All Projects → phptek → Silverstripe Jsontext

phptek / Silverstripe Jsontext

Licence: other
JSON storage and querying

Labels

Projects that are alternatives of or similar to Silverstripe Jsontext

Yaml.js
Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.
Stars: ✭ 810 (+3581.82%)
Mutual labels:  json
Acf 5 Pro Json Storage
Save ACF 5 Pro field groups as JSON within this plugin, rather than inside your theme.
Stars: ✭ 16 (-27.27%)
Mutual labels:  json
Defiant.js
http://defiantjs.com
Stars: ✭ 907 (+4022.73%)
Mutual labels:  json
Jsonlite
A simple, self-contained, serverless, zero-configuration, json document store.
Stars: ✭ 819 (+3622.73%)
Mutual labels:  json
Json to dart
Library that generates dart classes from json strings
Stars: ✭ 836 (+3700%)
Mutual labels:  json
Html2json
Lightweight library that converts a HTML webpage to JSON data using a template defined in JSON.
Stars: ✭ 18 (-18.18%)
Mutual labels:  json
Kt
Kafka command line tool that likes JSON
Stars: ✭ 799 (+3531.82%)
Mutual labels:  json
Spray Json
A lightweight, clean and simple JSON implementation in Scala
Stars: ✭ 917 (+4068.18%)
Mutual labels:  json
Csharpjson
C# 编写的通用Json数据解析库
Stars: ✭ 16 (-27.27%)
Mutual labels:  json
Sanest
sane nested dictionaries and lists for python
Stars: ✭ 19 (-13.64%)
Mutual labels:  json
Bludit
Simple, Fast, Secure, Flat-File CMS
Stars: ✭ 824 (+3645.45%)
Mutual labels:  json
Jackson Module Kotlin
Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Stars: ✭ 830 (+3672.73%)
Mutual labels:  json
Raccoon Plugin
With Raccoon, use a JSON or YAML file to manage WordPress theme features
Stars: ✭ 18 (-18.18%)
Mutual labels:  json
Dyson
Node server for dynamic, fake JSON.
Stars: ✭ 814 (+3600%)
Mutual labels:  json
Easy Mock Server
A mock server for json and mock template files
Stars: ✭ 22 (+0%)
Mutual labels:  json
Gojq
Pure Go implementation of jq
Stars: ✭ 800 (+3536.36%)
Mutual labels:  json
Json Chunks
streamable json encoder
Stars: ✭ 17 (-22.73%)
Mutual labels:  json
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+4059.09%)
Mutual labels:  json
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (+0%)
Mutual labels:  json
Movement
Movement is an easier, simpler way to explore and use NIEM. Want to join the Movement and contribute to it? Start here.
Stars: ✭ 19 (-13.64%)
Mutual labels:  json

SilverStripe JSONText

Build Status Scrutinizer Code Quality License

Exposes a complete API that allows developers to write-to, and query-from JSON in a dedicated DBField subclass.

In addition, if your project uses the silverstripe/cms package, then all SiteTree objects are automatically extended to allow multiple, arbitrary UI fields as declared in getCMSFields(), to write to a JSON object in a single database field.

Using JSONPath (Think XPath but for JSON) and the module's extensive API, developers can selectively target specific JSON keys for modification.

Requirements

SilverStripe 4

  • Use ^2.0
  • PHP >=5.6, <=7.1

SilverStripe 3

  • Use ^1.0
  • PHP >=5.4, <7.0

Features

  • Store JSON "object-strings" in a JSON-specific DBField subclass.
  • Query stored JSON via simple accessors: first(), last() & nth() or Postgres-like operators: ->, ->> & #> or even JSONPath expressions.
  • Selectively return query-results as JSON, Array or cast to SilverStripe's DBVarchar, DBInt, DBFloat or DBBoolean objects.
  • Selectively update portions of stored JSON using JSONPath expressions.
  • Selectively transform one or more CMS input fields, to write to a single JSON store.

Introduction

The module exposes a fully featured JSON query and update API allowing developers to use XPath-like queries via JSONPath or Postgres' JSON operators (with some differences, see below) to query and update JSON data.

Why?

Project scenarios where storing 10s of terse configuration parameters as Booleans and Ints in separate database columns just seems crazy.

When all you wanted was a simple key / value store but didn't want to muck about with the overhead of an RDBMS and a NOSQL DB.

That Postgres, MySQL, Oracle and MSSQL 2016 all have, or at time of writing, are planning to have, Database level JSON field-types. This module plugs the gap for users of RDBMS' without native JSON support, while offering the a convenient scaffold on top of which native JSON support could be built.

Postgres

In Postgres both the -> and ->> operators act as string and integer key matchers on a JSON array or JSON object respectively. The module however treats both source types the same - they are after all both JSON so -> is used as an Integer Matcher and ->> as a String Matcher regardless of the "type" of source JSON stored. The #> Path Matcher operator can act as an object or a text matcher, but the module wishes to simplify things and as such the #> operator is just a simple path matcher.

Return types

Regardless of the type of query you can set what type you'd like the data returned in via the setReturnType() method on a query by query basis.

Legitimate types are:

  • JSON
  • Array
  • SilverStripe

If using SilverStripe as the return type, the module will automatically cast the result(s) to one of SilverStripe's DBObject subtypes:

  • DBBoolean
  • DBInt
  • DBFloat
  • DBVarchar

If there are multiple results from a query, the output will be an indexed array containing a single-value array for each result found.

The module also allows developers to selectively update all, or just parts of the source JSON, via JSONPath expressions passed to an overloaded setValue() method.

See the usage docs for examples of JSONPath and Postgres querying and updating.

Note: This module's query API is based on a relatively simple JSON to array conversion principle. It does not use Postgres' or MySQL's native JSON operators at or below the level of the ORM. The aim however is to allow dev's to use their preferred DB's syntax, and to this end you can set the module into mysql or postgres mode using SS config, see Configuration Docs.

Installation

#> composer require phptek/jsontext

Configuration

See: Configuration Docs.

Usage

See: Usage Docs.

Contributing

If you've been using Postgres or MySQL with its JSON functions for some time, I'm keen to hear from you. Some simple failing tests would be most welcome.

See: CONTRIBUTING.md.

Reporting an issue

Please include all details, no matter how small. If it were your module, what would you need to know from a bug/feature request? :-)

Credits

Author

Russell Michell 2016-2018 [email protected]

TODO

  • Add missing prepValueForDB() to JSONText class.
  • See official list of issues on GitHub.

Support Me

If you like what you see, support me! I accept Bitcoin:

Bitcoin
3KxmqFeVWoigjvXZoLGnoNzvEwnDq3dZ8Q

 

 

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].