Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

JSON object behaviour in populateObjects 16 Sep 2013 09:48 #11102

for some unknown reason to me, the code in the function populateObjects:
		if (!empty($item->my_json_object))
		{
			$registry = new JRegistry;
			$registry->loadString($item->my_json_object);
			$item->my_json_object = new JObject($registry->toObject());
		}

return an empty object when I call directly the $model->getItem()

if I use the simple json_decode, it always perfectly works:
		if (!empty($item->my_json_object) AND is_string($item->my_json_object))
		{
			$item->my_json_object = json_decode($item->my_json_object);
		}

Please Log in or Create an account to join the conversation.

JSON object behaviour in populateObjects 23 Sep 2013 17:53 #11154

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed since 2.6
$item->my_json_object = new JObject($registry->toObject());

To:
$item->my_json_object = $registry->toObject();

Simple...
Coding is now a piece of cake
The following user(s) said Thank You: Tomaselli

Please Log in or Create an account to join the conversation.

JSON object behaviour in populateObjects 27 Sep 2013 11:24 #11198

Thanks for the fix.
I noticed a little bug when the function populateObjects is called again (for example when you call the function getForm).
In this situation the function populateObjects will overwrite the JSON object and the data will be deleted, to avoid that afurther check should be added:

Original jcook 2.6:
		if (!empty($item->my_json_obejct))
		{
			$registry = new JRegistry;
			$registry->loadString($item->my_json_obejct);
			$item->my_json_obejct = $registry->toObject();
		}

Modified:
		if (!empty($item->my_json_obejct) AND is_string($item->my_json_obejct)) /* hack */
		{
			$registry = new JRegistry;
			$registry->loadString($item->my_json_obejct);
			$item->my_json_obejct = $registry->toObject();
		}
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

JSON object behaviour in populateObjects 27 Sep 2013 11:28 #11199

I'm also thinking that function populateObejcts should be called just ONCE on the same Item (and it is called more than once), shouldn't be added a static variable to check that?

Please Log in or Create an account to join the conversation.

JSON object behaviour in populateObjects 07 Oct 2013 00:19 #11303

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed now.
Coding is now a piece of cake
The following user(s) said Thank You: Tomaselli

Please Log in or Create an account to join the conversation.

JSON object behaviour in populateObjects 08 Oct 2013 07:58 #11328

thank you

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.084 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started