playMaker

Author Topic: Datamaker Convert XML to JSON resulting null  (Read 2032 times)

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
Datamaker Convert XML to JSON resulting null
« 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?


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Datamaker Convert XML to JSON resulting null
« Reply #1 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.

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Datamaker Convert XML to JSON resulting null
« Reply #2 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Datamaker Convert XML to JSON resulting null
« Reply #3 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.

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Datamaker Convert XML to JSON resulting null
« Reply #4 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"
   ]
}

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Datamaker Convert XML to JSON resulting null
« Reply #5 on: July 17, 2020, 03:04:41 AM »
Hi.
I just noticed your other thread, maybe you should mention it there as it might be related with similar reasons.

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Datamaker Convert XML to JSON resulting null
« Reply #6 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Datamaker Convert XML to JSON resulting null
« Reply #7 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker Convert XML to JSON resulting null
« Reply #8 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

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Datamaker Convert XML to JSON resulting null
« Reply #9 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker Convert XML to JSON resulting null
« Reply #10 on: July 21, 2020, 01:13:52 AM »
Hi,

I though you wanted to convert json to xml?

Bye,

 Jean

tengkunash99

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Datamaker Convert XML to JSON resulting null
« Reply #11 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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker Convert XML to JSON resulting null
« Reply #12 on: July 22, 2020, 07:50:37 AM »
Hi,

 ok, I mistaken with your other issue...

Bye,

 Jean