json_encode object
Posté : 15 nov. 2015, 16:47
Bonjour à tous,
J'ai l'objet suivant à traiter:
Je fais un json_encode , puis un json_decode sur l'objet encodé pour voir ce qui sort:
Le résultat du var_dump est inattendu. J'obtiens:
En vous remerciant pour vos réponses.
J'ai l'objet suivant à traiter:
Code : Tout sélectionner
JForm Object
(
[data:protected] => Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
)
[separator] => .
)
[errors:protected] => Array
(
)
[name:protected] => item_component
[options:protected] => Array
(
[control] =>
)
[xml:protected] => SimpleXMLElement Object
(
[fields] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => params
[label] => COM_MENUS_LINKTYPE_OPTIONS_LABEL
)
[fieldset] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu-options
[label] => COM_MENUS_LINKTYPE_OPTIONS_LABEL
)
[field] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu-anchor_title
[type] => text
[label] => COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL
[description] => COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu-anchor_css
[type] => text
[label] => COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL
[description] => COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu_image
[type] => media
[label] => COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL
[description] => COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu_text
[type] => radio
[class] => btn-group btn-group-yesno
[label] => COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL
[description] => COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC
[default] => 1
[filter] => integer
)
[option] => Array
(
[0] => JYES
[1] => JNO
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => page-options
[label] => COM_MENUS_PAGE_OPTIONS_LABEL
)
[field] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => page_title
[type] => text
[label] => COM_MENUS_ITEM_FIELD_PAGE_TITLE_LABEL
[description] => COM_MENUS_ITEM_FIELD_PAGE_TITLE_DESC
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => show_page_heading
[type] => list
[class] => chzn-color
[label] => COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_LABEL
[description] => COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_DESC
[default] =>
)
[option] => Array
(
[0] => JGLOBAL_USE_GLOBAL
[1] => JYES
[2] => JNO
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => page_heading
[type] => text
[label] => COM_MENUS_ITEM_FIELD_PAGE_HEADING_LABEL
[description] => COM_MENUS_ITEM_FIELD_PAGE_HEADING_DESC
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => pageclass_sfx
[type] => text
[label] => COM_MENUS_ITEM_FIELD_PAGE_CLASS_LABEL
[description] => COM_MENUS_ITEM_FIELD_PAGE_CLASS_DESC
)
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => metadata
[label] => JGLOBAL_FIELDSET_METADATA_OPTIONS
)
[field] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu-meta_description
[type] => textarea
[label] => JFIELD_META_DESCRIPTION_LABEL
[description] => JFIELD_META_DESCRIPTION_DESC
[rows] => 3
[cols] => 40
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => menu-meta_keywords
[type] => textarea
[label] => JFIELD_META_KEYWORDS_LABEL
[description] => JFIELD_META_KEYWORDS_DESC
[rows] => 3
[cols] => 40
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => robots
[type] => list
[label] => JFIELD_METADATA_ROBOTS_LABEL
[description] => JFIELD_METADATA_ROBOTS_DESC
)
[option] => Array
(
[0] => JGLOBAL_USE_GLOBAL
[1] => JGLOBAL_INDEX_FOLLOW
[2] => JGLOBAL_NOINDEX_FOLLOW
[3] => JGLOBAL_INDEX_NOFOLLOW
[4] => JGLOBAL_NOINDEX_NOFOLLOW
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => secure
[type] => list
[label] => COM_MENUS_ITEM_FIELD_SECURE_LABEL
[description] => COM_MENUS_ITEM_FIELD_SECURE_DESC
[default] => 0
[filter] => integer
)
[option] => Array
(
[0] => JOFF
[1] => JON
[2] => COM_MENUS_FIELD_VALUE_IGNORE
)
)
)
)
)
)
)
[repeat] =>
)
object(stdClass)#209 (1) {
["repeat"]=>
bool(false)
}
Code : Tout sélectionner
$encoded = json_encode($obj);
$decoded = json_decode($encoded);
var_dump($decoded);
Pourquoi l'objet a-t-il été complètement détruit par la fonction Json_encode?object(stdClass)#209 (1) {
["repeat"]=> bool(false)
}
En vous remerciant pour vos réponses.