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.097 seconds

  I found "cook" two days ago. Played around with it for a day and then within a day got rid of two legacy applications in IBM Lotus Domino Notes and replaced them with "cook". It was really easy. A piece of cake. Actually it was even easier than cooking. Cooking involves more work than developing with "cook". What can I say about "cook"? Great application great price for what it delivers great forum with a lot of information and fast responses active and friendly community fast forward moving development cycle So what should I say "Monsieur Le Cook"? Keep the good work going it will lead to success. Having become a paying member in the words of Edith Piaf may I say ..... non rien de rien ... je ne regrette rien. Vive La France.
FK (JED)
         

Get Started