1

Is there any way to get PHP classes mapped from json (something like JAXB for Java) ?

For example:

{"name":"MIckey", "surname":"Mouse", "age":20, "cars":[{"plate":"1234","model":"Test"},{"plate":"5678","model":"Test"}]}

creates:

class Man{
    private $name;
    private $surname;
    private $age;
    private $cars;

    ...get
    ...set
}

class Car{
    private $plate;
    private $model;

    ...get
    ...set
}
Tobia
  • 9,165
  • 28
  • 114
  • 219

1 Answers1

0

Here's one that will produce PHP classes. https://packagist.org/packages/kshabazz/json-to-src

It's a bit clunky, but the only one that I know of that will generate actual PHP files.

It's meant to work with API services that do not provide a JSON schema. You have to provide the actual JSON that the API spits out.

b01
  • 4,076
  • 2
  • 30
  • 30