{"id":37015738,"url":"https://github.com/phptek/silverstripe-jsontext","last_synced_at":"2026-01-14T01:36:11.915Z","repository":{"id":57040874,"uuid":"60253582","full_name":"phptek/silverstripe-jsontext","owner":"phptek","description":"JSON storage and querying","archived":false,"fork":false,"pushed_at":"2024-05-21T00:34:02.000Z","size":160,"stargazers_count":22,"open_issues_count":7,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-12-26T02:48:16.435Z","etag":null,"topics":["json","jsonpath","multivalue","silverstripe"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phptek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-02T10:06:32.000Z","updated_at":"2023-04-07T00:12:16.000Z","dependencies_parsed_at":"2024-06-19T15:10:49.987Z","dependency_job_id":null,"html_url":"https://github.com/phptek/silverstripe-jsontext","commit_stats":{"total_commits":103,"total_committers":3,"mean_commits":"34.333333333333336","dds":"0.12621359223300976","last_synced_commit":"9a125e6b84ee5bd84b38c688a913fba05aa5f5ef"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/phptek/silverstripe-jsontext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phptek%2Fsilverstripe-jsontext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phptek%2Fsilverstripe-jsontext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phptek%2Fsilverstripe-jsontext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phptek%2Fsilverstripe-jsontext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phptek","download_url":"https://codeload.github.com/phptek/silverstripe-jsontext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phptek%2Fsilverstripe-jsontext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","jsonpath","multivalue","silverstripe"],"created_at":"2026-01-14T01:36:10.633Z","updated_at":"2026-01-14T01:36:11.825Z","avatar_url":"https://github.com/phptek.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SilverStripe JSONText\n\n[![Build Status](https://api.travis-ci.org/phptek/silverstripe-jsontext.svg?branch=master)](https://travis-ci.org/phptek/silverstripe-jsontext)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/phptek/silverstripe-jsontext/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/phptek/silverstripe-jsontext/?branch=master)\n[![License](https://poser.pugx.org/phptek/jsontext/license.svg)](https://github.com/phptek/silverstripe-jsontext/blob/master/LICENSE.md)\n\nExposes a complete API that allows developers to write-to, and query-from JSON in a dedicated `DBField` subclass. \n\nIn 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.\n\nUsing JSONPath (Think XPath but for JSON) and the module's extensive API, developers can selectively target specific JSON keys for modification.\n\n## Requirements\n\n### SilverStripe 4\n\n* Use ^2.0\n* PHP \u003e=5.6, \u003c=7.1\n\n### SilverStripe 3\n\n* Use ^1.0\n* PHP \u003e=5.4, \u003c7.0\n\n## Features\n\n* Store JSON \"object-strings\" in a JSON-specific `DBField`  subclass.\n* Query stored JSON via simple accessors: `first()`, `last()` \u0026 `nth()` or Postgres-like operators: `-\u003e`, `-\u003e\u003e` \u0026 `#\u003e` or even [JSONPath](http://goessner.net/articles/JsonPath/) expressions.\n* Selectively return query-results as `JSON`, `Array` or cast to SilverStripe's `DBVarchar`, `DBInt`, `DBFloat` or `DBBoolean` objects.\n* Selectively update portions of stored JSON using [JSONPath](http://goessner.net/articles/JsonPath/) expressions.\n* Selectively transform one or more CMS input fields, to write to a single JSON store.\n\n## Introduction\n\nThe module exposes a fully featured JSON query and update API allowing developers to use XPath-like queries via [JSONPath](http://goessner.net/articles/JsonPath/)\nor [Postgres' JSON operators](https://www.postgresql.org/docs/9.5/static/functions-json.html) (with some differences, see below) to query and update JSON data.\n\n### Why?\n\nProject scenarios where storing 10s of terse configuration parameters as Booleans and Ints in separate database columns just seems crazy. \n\nWhen 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.\n\nThat 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'\n_without_ native JSON support, while offering the a convenient scaffold on top of which native JSON support could be built.\n\n### Postgres\n\nIn Postgres both the `-\u003e` and `-\u003e\u003e` operators act as string and integer key matchers on a JSON array or JSON object respectively. The module\nhowever treats both source types the same - they are after all *both JSON* so `-\u003e` is used as an **Integer Matcher** and `-\u003e\u003e` as a **String Matcher**\n*regardless* of the \"type\" of source JSON stored. The `#\u003e` **Path Matcher** operator can act as an object or a text matcher, but the module wishes to simplify things and as such\nthe `#\u003e` operator is *just a simple path matcher*.\n\n### Return types\n\nRegardless 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. \n\nLegitimate types are:\n\n* JSON\n* Array\n* SilverStripe\n\nIf using `SilverStripe` as the return type, the module will automatically cast the result(s) to one of SilverStripe's `DBObject` subtypes:\n\n* `DBBoolean`\n* `DBInt`\n* `DBFloat`\n* `DBVarchar`\n\nIf there are multiple results from a query, the output will be an indexed array containing a single-value array for each result found.\n\nThe module also allows developers to selectively *update* all, or just parts of the source JSON, via JSONPath expressions passed\nto an overloaded `setValue()` method.\n\nSee [the usage docs](docs/en/usage.md) for examples of JSONPath and Postgres querying and updating.\n\nNote: This module's query API is based on a relatively simple JSON to array conversion principle. \nIt does *not* use Postgres' or MySQL's native JSON operators at or below the level of the ORM. The aim however \nis to allow dev's to use their preferred DB's syntax, and to this end you can set\nthe module into `mysql` or `postgres` mode using SS config, see [Configuration Docs](docs/en/configuration.md).\n\n## Installation\n\n    #\u003e composer require phptek/jsontext\n\n## Configuration\n\nSee: [Configuration Docs](docs/en/configuration.md).\n\n## Usage\n\nSee: [Usage Docs](docs/en/usage.md). \n\n## Contributing\n\nIf you've been using Postgres or MySQL with its JSON functions for some time,\nI'm keen to hear from you. Some simple failing tests would be most welcome.\n\nSee: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Reporting an issue\n\nPlease include all details, no matter how small. If it were *your module*, what would you need to know from a bug/feature request? :-)\n\n## Credits\n\n* [Axel Anceau](https://github.com/Peekmo/) for his packaging-up of the pretty amazing JSONPath implementation by [Stefan Goessner](https://code.google.com/archive/p/jsonpath/)\n* [Stefan Goessner](https://code.google.com/archive/p/jsonpath/) for the original work on JSONPath dating back to 2005!\n\n## Author\n\nRussell Michell 2016-2018 \u003cruss@theruss.com\u003e\n\n## TODO\n\n* Add missing `prepValueForDB()` to `JSONText` class.\n* See official list of issues on GitHub. \n\n## Support Me\n\nIf you like what you see, support me! I accept Bitcoin:\n\n\u003ctable border=\"0\"\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd rowspan=\"2\"\u003e\n\t\t\t\u003cimg src=\"https://bitcoin.org/img/icons/logo_ios.png\" alt=\"Bitcoin\" width=\"64\" height=\"64\" /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\n\t\t\t\u003cb\u003e3KxmqFeVWoigjvXZoLGnoNzvEwnDq3dZ8Q\u003c/b\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphptek%2Fsilverstripe-jsontext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphptek%2Fsilverstripe-jsontext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphptek%2Fsilverstripe-jsontext/lists"}