MediaSignage support forum

community support => Internet Of Things => Topic started by: blackfox123 on October 01, 2015, 05:35:21 AM

Title: UserDomain JSON malformed
Post by: blackfox123 on October 01, 2015, 05:35:21 AM
Hi, I am trying to get the userdomain etc to send an event with my application. However, upong recieving the JSON from the

https://galaxy.signage.me/WebService/getUserDomain.ashx?i_userpass=********

service, the JSON is incorrect and does not validate.. causing my app to fail the parsing. This is according to a few online validation sites.
Title: Re: UserDomain JSON malformed
Post by: admin on October 01, 2015, 10:42:00 AM
Use this new link to test: http://signage.me/demo/testsendcommand.html
be sure to provide all proper fields including station id
Title: Re: UserDomain JSON malformed
Post by: blackfox123 on October 01, 2015, 10:58:07 AM
Maybe you misunderstand..

The JSON that the galaxy.signage.me webservice produces isn't correct, it's not validated JSON.. This i am referring to the output of

var url1= 'https://galaxy.signage.me/WebService/getUserDomain.ashx?i_userpass='+userpass64+'&callback=?';

Within my php script i have to re-parse the JSON to get the user domain with some very funky codes and regexes. e.g.:

Code: [Select]
function tidyup($s) {
  $s = str_replace(array( '(', ')' ), '', $s);

  $s = str_replace(
      array('"',  "'"),
      array('"', '"'),
      $s
  );
  $s = preg_replace('/(\w+):/i', '"\1":', $s);
  return $s;
}

This procudes the correct validated JSON form from your webservice
Title: Re: UserDomain JSON malformed
Post by: admin on October 01, 2015, 11:07:29 AM
the returned JSON is used by hundreds of players so I am not sure why PHP is complaining... :/
Title: Re: UserDomain JSON malformed
Post by: blackfox123 on October 01, 2015, 11:42:30 AM
Sure, within javascript.

However, if you try and send the JSON output to an online validator it complains.

http://www.ietf.org/rfc/rfc4627.txt?number=4627

I.E with the RFC in example 8, it differs from the output from your webservice. The addition of parenthesis and not enclosing the keys in quotation marks to be specific. Its not a huge problem it's easy enough to hack away on my end.. but it does not conform to standards.
Title: Re: UserDomain JSON malformed
Post by: admin on October 05, 2015, 09:52:55 AM
you can try a diff PHP lib? or, convert the JSON to string with basic removal of the extra parentheses (i.e.: like regexp) and convert back to true JSON object as workaround.
Title: Re: UserDomain JSON malformed
Post by: blackfox123 on October 06, 2015, 12:23:39 AM
Thats what i did (see above) however my point is, it's incorrect JSON format == bad programming. RFCs are there for a reason, to be followed, and if not compatibility becomes an issue.
Title: Re: UserDomain JSON malformed
Post by: admin on October 06, 2015, 01:01:15 PM
ok will open PR for dev to check, regards
Title: Re: UserDomain JSON malformed
Post by: mayte on April 11, 2017, 09:18:38 AM
Yep, JSON still malformed. Thanks blackfox123 I used your code to fix-it in PHP.

Mayte