Playmaker Forum
PlayMaker News => General Discussion => Topic started 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?
-
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.
-
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.
-
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.
-
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"
]
}
-
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.
-
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.
-
Hi.
Its not really completely different to other is convert from json to xml and both related from the same package.
-
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
-
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.
-
Hi,
I though you wanted to convert json to xml?
Bye,
Jean
-
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
-
Hi,
ok, I mistaken with your other issue...
Bye,
Jean