Download the PHP package vanilla/garden-jsont without Composer

On this page you can find all versions of the php package vanilla/garden-jsont. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package garden-jsont

Garden JSON Transform

Packagist Version MIT License CI CLA

A little library that transforms data based on a specification that can be expressed in JSON.

Purpose

The purpose of this package is to provide simple data transformation that can be applied to arrays of data like those that come from JSON APIs. The transformations are specified in simple arrays so that an entire transformation specification can also be serialized to JSON, making this a completely data-driven library.

The Transformer Class

The heart of this library is the Transformer class that takes a transformation spec in its constructor and then uses that spec to tell it how to transform data.

The Transformer class is also callable so it can be passed as an argument that requires a callback such as array_map.

Transformation Specs

A transformation spec is an associated array that contains all of the keys of the target array, but with values that are JSON references to keys in the source array.

You can see from the above, you can reference a nested value using a forward slash to separate nested references.

Nested Data

For complex target arrays you nest keys by structuring the target like your desired data format:

Default Values

If you reference a key that doesn't exist in the source data then it will be omitted in the transformed data. If you want to provide a default value you can use the following spec:

If you omit the $default value then the default value is assumed to be null.

Transforming arrays with $each

You can loop through an array and transform each item using $each and $item.

The above would transform an array like this:

Into this:

You can aso specify a transform for the keys in an array using the $key attribute. Here is an example spec:

This spec would transform the example from above into this:

Absolute vs. Relative References

You may have noticed that the references most of the examples all start with a / character. This is because they are all absolute references.

If you don't use a / at the beginning of your reference then you are specifying a relative reference. You use relative references in the $item spec to refer to items within the loop.

Literal Values

Sometimes you might want to provide a specific literal value in the result. You can do this with the $literal key.

Why doesn't this library do enough?

Some people think this library is flimsy, foolish, and not worth worrying about. But don't you believe it! The initial implementation of this package is intended to provide the minimum amount of functionality to be useful for 90% of problems.

Any sensible features will be added as requirements evolve. However, they must adhere to the core purpose of this package: transformations that can be expressed as plain JSON.


All versions of garden-jsont with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vanilla/garden-jsont contains the following files

Loading the files please wait ....