PHPackages                             kurianvarkey/helper-buddy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kurianvarkey/helper-buddy

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kurianvarkey/helper-buddy
=========================

Helper class to validate and correct JSON attribute types, ensuring proper structure and defaults for string, int, float, and boolean.

v1.0.2(1y ago)129MITPHPPHP ^8.1

Since May 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kurianvarkey/helper-buddy)[ Packagist](https://packagist.org/packages/kurianvarkey/helper-buddy)[ RSS](/packages/kurianvarkey-helper-buddy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Package with some array and json helper methods
===============================================

[](#package-with-some-array-and-json-helper-methods)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require kurianvarkey/helper-buddy
```

JsonBuddy
---------

[](#jsonbuddy)

A json helper class to validate json structure. You can validate json structure by providing a list of keys and types.

- Supported types: string, array, object, int, float, decimal, boolean / bool
- Format: "path" =&gt; "type:default" (default is optional and only used when type is string, int, float, bool)
- Note: if the final attribute in the path doesn't exist, it will be created

For example

```
{
  "name": null,
  "structure": [
    {
      "rows": [
        {
          "columns": [
            {
              "price": null,
              "data": []
            },
            {
              "price": 2,
              "data": []
            }
          ]
        },
        {
          "columns": [
            {
              "price": 1,
              "data": {
                "name": "data 1"
              }
            }
          ]
        }
      ]
    }
  ]
}

```

```
