Instantiate an stdClass object from json schema specification in PHP -


i have set of json requests must send restful api in order response objects, know, usual thing webapp, these api request objects documented json schema specification each, load schema files , create stdclass object instances based on info automagically.

is there way library or in php? (don't want reinvent wheel)

thanks!

edit: have @ this schema file contains example of want load , build object instances from.

disclaimer: know json_encode / json_decode not i'm looking for. using i'd need traverse through returned schema object , create object/array based on schema read, not want.

i don't think there's built-in way of doing this, should relatively trivial implement:

function createobj( $json ) {     $obj_schema = json_decode($json, true);     $new_obj = new stdclass;     foreach($obj_schema['properties'] $property) {       $new_obj->{$property} = null;     }      return $new_obj; } 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -