Playmaker Forum

PlayMaker News => General Discussion => Topic started by: tengkunash99 on July 15, 2020, 09:59:34 PM

Title: Datamaker Convert XML to JSON resulting null
Post by: tengkunash99 on July 15, 2020, 09:59:34 PM
I try to google for sample on net and this forum but could not find the proper way to use "Convert XML to JSON" action. My json result is null. Did I miss anything?

Title: Re: Datamaker Convert XML to JSON resulting null
Post by: djaydino on July 16, 2020, 06:52:26 AM
Hi.
Not sure if that works, but try setting the convert action in a separate state

and maybe also the xml refresh

To make sure the actions has finished before the convert is started.

you can also right click in a state Window and enable Sequence, this will make sure that a action only starts when the previous has finished.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: tengkunash99 on July 16, 2020, 10:27:33 AM
Hi,

When you said not sure if that works, does it mean there is a certain format to convert XML to JSON, if there how? I could not find it. I already separate into several state. The result is still same. and also enable the action sequence.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: djaydino on July 16, 2020, 11:30:04 AM
Hi.
Well i know xml actions can be 'slow', so if they are in the same state it could be that Convert is already started 'before' Xml get as string is finished

Maybe you need this line to be included to make conversion work?

<?xml version="1.0" encoding="utf-8"?>

I never tried converting yet to json btw, i will ping jean to have a look to this post.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: tengkunash99 on July 17, 2020, 12:32:34 AM
Hi Djaydino,

I tried delay it for couple of seconds the result is still same. I wonder if I really need to include this <?xml version="1.0" encoding="UTF-8"?> in xml then how my original JSON format will look like. Currently my original JSON I load from cloud is this.

"17_jigsaw_kangaroo_scene1": {
   "LevelSelection": [
      "true",
      "false",
      "true",
      "false"
   ]
}
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: djaydino on July 17, 2020, 03:04:41 AM
Hi.
I just noticed your other thread (https://hutonggames.com/playmakerforum/index.php?topic=22388.0), maybe you should mention it there as it might be related with similar reasons.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: tengkunash99 on July 17, 2020, 05:45:30 AM
Hi Djaydino

Actually it is a completely two different issue on different playmaker action. Thats why I am separating it into two post. Currently I am still stuck on this two issue and not able to find a workaround.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: djaydino on July 17, 2020, 08:36:48 AM
Hi.
Its not really completely different to other is convert from json to xml and both related from the same package.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: jeanfabre on July 20, 2020, 02:40:16 AM
Hi,

 I am on it, I haven't found why it does that yet, it's all within the newtonsoft dll I am using, so not sure what I can do, but I am experimenting to see what could cause this.

Bye,

 Jean
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: tengkunash99 on July 20, 2020, 05:03:24 AM
Hi,

I am using this as current workaround.

XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlReference.Value);
string jsonText = JsonConvert.SerializeXmlNode(doc);
jsonResult.Value = jsonText;

Cheers.
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: jeanfabre on July 21, 2020, 01:13:52 AM
Hi,

I though you wanted to convert json to xml?

Bye,

 Jean
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: tengkunash99 on July 21, 2020, 03:12:46 AM
Hi,

No, json to xml is working fine. The issue is xml to json will give null value. But I already post the current workaround that fix the issue. Maybe you can have a look.

Bye,

 Jean
Title: Re: Datamaker Convert XML to JSON resulting null
Post by: jeanfabre on July 22, 2020, 07:50:37 AM
Hi,

 ok, I mistaken with your other issue...

Bye,

 Jean