December 17, 2017, 05:13:46 PM
Welcome, Guest. Please login or register
News: Join us for a FREE Webinar this Thursday at http://webinar.digitalsignage.com

MediaSignage support forum



Author Topic: UserDomain JSON malformed  (Read 2287 times)

blackfox123

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
UserDomain JSON malformed
« 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.

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 4737
  • Karma: +35/-8
    • View Profile
Re: UserDomain JSON malformed
« Reply #1 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

blackfox123

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: UserDomain JSON malformed
« Reply #2 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

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 4737
  • Karma: +35/-8
    • View Profile
Re: UserDomain JSON malformed
« Reply #3 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... :/

blackfox123

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: UserDomain JSON malformed
« Reply #4 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.

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 4737
  • Karma: +35/-8
    • View Profile
Re: UserDomain JSON malformed
« Reply #5 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.

blackfox123

  • Jr. Member
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: UserDomain JSON malformed
« Reply #6 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.

admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 4737
  • Karma: +35/-8
    • View Profile
Re: UserDomain JSON malformed
« Reply #7 on: October 06, 2015, 01:01:15 PM »
ok will open PR for dev to check, regards

mayte

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: UserDomain JSON malformed
« Reply #8 on: April 11, 2017, 09:18:38 AM »
Yep, JSON still malformed. Thanks blackfox123 I used your code to fix-it in PHP.

Mayte

 

Carbonate design by Bloc
variant: carbon
SMF 2.0.12 | SMF © 2016, Simple Machines