Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jsonmapper Laravel Package

apimatic/jsonmapper

apimatic/jsonmapper is a lightweight PHP JSON-to-object mapper for converting API responses into typed models. It maps arrays/JSON to class properties with minimal setup, supports nested structures, and helps keep data hydration consistent across your application.

View on GitHub
Deep Wiki
Context7
3.1.7

3.1.7 (2025-11-06)

Bug Fixes

  • adds multiple discriminator values support for a single type (#67) (b2444c3)

Documentation

  • adds contributing guide and issue templates (#59) (45b9f4d)
  • adds the missing osl license file (#64) (6b9fd3f)

Continuous Integration

  • dependabot: slack alert (#60) (9f98091)
  • dependabot: update the configurations for dependabot alerts (#56) (3d221b2)
  • add SonarCloud coverage reporting (#62) (c487e48)
  • add SonarQube scan to CI workflow (#61) (3ed9aff)
3.1.6

3.1.6 (2024-11-28)

Bug Fixes

  • additional-properties: ignore exception when additional properties' method is missing (#55) (c6cc21b)
3.1.5

3.1.5 (2024-11-28)

Features

  • additional-properties: adds support for typed additional properties (#54) (540f642)
3.1.4

3.1.4 (2024-06-12)

Features

  • support for mapping inner nullable types in arrays (#52) (407b455)

Continuous Integration

3.1.3

3.1.3 (2024-03-15)

Bug Fixes

  • applies isEnabled condition to parse_ini_file function call (#48) (5fe6ee7)

Continuous Integration

3.1.2

3.1.2 (2023-06-08)

Bug Fixes

  • ini-parsing: added support for open_basedir restrictions (#41) (6673a94)
3.1.1

3.1.1 (2023-05-08)

Features

  • runtime-exception: convert JsonMapperException into RuntimeException (#40) (646a308)
3.1.0

3.1.0 (2023-05-03)

Features

  • oaf-discriminators: support discriminators for oneof/anyof (#38) (aa5542f)
3.0.7

3.0.7 (2023-04-04)

Features

  • language version upgrade: upgrade PHP language version to 8.2 (8373a90)

Build Systems

  • extend-php-support: extend php versions support to 8.x (#36) (c877632)
3.0.6

3.0.6 (2023-02-16)

Continuous Integration

  • security-enhancement: setup dependency review and release approvals (#32) (b74416e)
v3.0.5

This release fixes a bug where jsonmapper is unable to deserialize the json to a Child class when the Parent class exists in a different namespace.

v3.0.4

This release brings the following improvement in oneof/anyof features:

Now JsonMapper also support checking for a type of any given value in the provided type group, with jsonMapper's method checkTypeGroupFor. Following code sample demonstrate how one can check the type of any value.

$mapper = new JsonMapper();
$value = new Car();
$value = $mapper->checkTypeGroupFor('oneof(Car,Atom)', $value);

Here checkTypeGroupFor will throw a JsonMapperException if value's type didn't exist in the provided type group.

v3.0.3

With this release, we have added following:

  • Support added for strict type checking in model's fields inside any oneof/anyof cases.
  • Refactored JsonMapperException class to hold all relevant exceptions that can be thrown by the library at one place.
  • Refactored TypeCombination class to increase the performance of the library.
v3.0.2

This release includes a bug fix that may arise while initialization of JsonMapper, if php.ini file is not loaded

v3.0.1
  • Throw a JsonMapperException if PHP configuration discards comments, by some setting in the configuration file or locally.
  • Add tests related to the changes.
  • Enable tests in .yml file for PHP 8.1 and compatibility changes.
v3.0.0

This release brings support for mapping oneOf or anyOf between two or more types onto any given value in JsonMapper, it includes following changes:

  1. Addition of [@mapsBy](https://github.com/mapsBy) annotation for setters that describes the types that should map the value given for the field name described in [@maps](https://github.com/maps) annotation.
  2. [@factory](https://github.com/factory) annotation for setters can now hold the return Type for deserialization method, along with its path.
  3. Addition of public method mapFor() which provides mapping for any value by the provided types. It takes value as first argument while the types as second argument.

Types must be provided in a specific string format, in both [@mapsBy](https://github.com/mapsBy) and mapFor(). Let A, B are any two types, then:

  • oneOf(A,B) represents either A or B not both.
  • anyOf(A,B) represents either A, B or both.
  • oneOf(A,B)[] represents an array where an element can either be A or B not both
  • anyOf(A,B)[] represents an array where an element can either be A, B or both.
  • array<string,oneOf(A,B)> represents a map where an element can either be A or B not both.
  • array<string,anyOf(A,B)> represents a map where an element can either be A, B or both.
  • In all the above formats A or B might represent a simple type like string, int, Model, float[] or they may also represent a combination of types like, anyOf string and int i.e. anyOf(string,int), or oneOf Car and map of float i.e. oneOf(Car,array<string,float>) etc.

Following code snippet explain how to use this feature:

$mapper = new JsonMapper();
$contactOrStringObject = $mapper->mapFor($value, 'oneOf(string,Contact)');

This is how JsonMapper ensures that no other types can be mapped on the provided value but only string or Contact, if value is not one of the given types then mapFor() will throw JsonMapperException.

v2.0.3

This release fixes a minor bug in the library which caused warnings when used in exactly PHP 8.0.0 runtime.


Thanks for @mr-feek for submitting PR #9.

v2.0.2

This release fixes errors and warnings reported by PHP when JsonMapper was used with PHP >= 8.0.

This release does not add support for new language features introduced in PHP 8. That should be addressed in a later release.

Contributors

Thanks to @bakerkretzmar and @Dry7 for the PRs #7 and #6.

v2.0.1

When mapping a field of array type, the PHP 7 type is too generic. The JsonMapper should have inspected the [@param](https://github.com/param) annotation in the Docblock comment for a hint on what the element type for the array is and used this information to map the array of complex types correctly. However, this was not happening in the case of an array OR nullable type i.e ?array PHP type-hint. Instead, an array of stdClass was being created for an array of complex types.

This release fixes this issue. Just update your JsonMapper version to receive the fix.

v2.0.0
  1. Adds support for mapping to classes that have non-default constructors. Arguments are passed to the ctor based on the parameter name and type and matching setter.
  2. Adds support for [@map](https://github.com/map) and [@factory](https://github.com/factory) annotations to setter methods. Previously, only class fields were supported with these annotations.
  3. Improves test coverage by adding new unit tests.

Since this release changes the mapping behavior for classes that have non-default constructors, we are bumping up by a major version number.

v1.3.1

This release fixes warnings reported by PHP when JsonMapper was used with PHP >= 7.0. Other changes include:

  • Dropped support for legacy PHP versions 5.4 and 5.5 and HHVM. JsonMapper might work with these versions but we no longer test with them.
  • Some warnings reported by PHP 7.* when running PHPUnit and PHP Code Sniffer were fixed by updating versions.
v1.3.0

Factory Method annotation allows you to specify a method which will be used to initialize a property on the object. This annotation can be applied per property.

v1.2.0
v1.1.0

Added supported for polymorphic mappings using a discriminator tag.

v1.0.2
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport