I have a class with some properties like id, name and stuff and some functions.
When i JSON encode it and send to my program I JSON decode it and get an object with the same properties as my class but without the functions of the class...
Is there a smart way of turning this JSON object to an object of my class or do i have to copy property for property?
As I do now:
Code: Select all
$product = new Models\Product;
$obj = json_decode($_POST["product"]);
$product->name = $obj->name;
$product->grossweight = $obj->grossweight;
$product->gw_unit = $obj->gw_unit;
$product->netweight = $obj->netweight;
$product->nw_unit = $obj->nw_unit;
Thanks