You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@royale.apache.org by Jim McNamara <ro...@yahoo.com> on 2022/06/18 14:19:45 UTC

json input parser won't parse regular array or indexed array: please help

Hi all-

I am stuck on my php_amf3 remoting code.

The offending line is something like this (from memory)

var ji:JSONInputParser;

input1.text = ji.parseItems('["foo", "bar"]').length.toString();

input1.text= ji.parseItems(' { "foo" : "bar" }').length.toString();

one is like an associative array and the other is like index in json format.

They won't print out in my text box. I'd really like the associative one to  work because that is what php_amf3 needs. If we can get this to work, I am quite certain that php_amf3 will work with arrays.

Please make a suggestion or confirm it is broken, and if so, I will do a bug report!

thanks


Re: json input parser won't parse regular array or indexed array: please help

Posted by Jim McNamara <ro...@yahoo.com>.
Hi Yishay,

I just tried out JSON.parse(); I like the following code a little better.

 public function formatJson(fs:String, p:String, r:int):String{
// THIS FUNCTION PARSES ANONYMOUS OBJECTS
// PHP SIMPLE SYNTAX CONVERTS ENCODED JSON ARRAY TO ANONYMOUS OBJECT
// OR YOU CAN JUST SKIP THE JSON ENCODING AND PASS AN ANONYMOUS OBJECT literal IN PHP AMF3


// where fs is something like this:
fs={"baseball":"sox", "basketball":""celtics"};
var replaced:String=fs;

  
   var indx:int = 0;


   if (r==0){
   
  //  obj4=JSON.parse(fs); // GIVES KEYS BUT NOT VALUES
   
// for(var h2:String in obj4){
    //  replaced = replaced + " " + h2;
// 
      
    var p1:RegExp = new RegExp(":");
   while ( replaced.search(p1)>-1){
          replaced = replaced.replace( p1, "," );
          indx++;
       }


  
} else {
  
   var pattern:RegExp = new RegExp("\"");
   while ( replaced.search(pattern) >-1){
          replaced = replaced.replace( pattern, "" );
          indx++;
       }
       
}
      
       return replaced;



}

I might need JSON.parse in the future.
Thanks for letting me know about it.

jim




On Tuesday, June 21, 2022 at 03:49:32 AM EDT, Yishay Weiss <yi...@hotmail.com> wrote: 








I am not sure where JSONInputParser is used, but have you tried just using JSON.parse() ?

 


From: Jim McNamara
Sent: Saturday, June 18, 2022 5:19 PM
To: users@royale.apache.org
Subject: json input parser won't parse regular array or indexed array: please help


 

Hi all-

I am stuck on my php_amf3 remoting code.

The offending line is something like this (from memory)

var ji:JSONInputParser;

input1.text = ji.parseItems('["foo", "bar"]').length.toString();

input1.text= ji.parseItems(' { "foo" : "bar" }').length.toString();

one is like an associative array and the other is like index in json format.

They won't print out in my text box. I'd really like the associative one to  work because that is what php_amf3 needs. If we can get this to work, I am quite certain that php_amf3 will work with arrays.

Please make a suggestion or confirm it is broken, and if so, I will do a bug report!

thanks

 



RE: json input parser won't parse regular array or indexed array: please help

Posted by Yishay Weiss <yi...@hotmail.com>.
I am not sure where JSONInputParser is used, but have you tried just using JSON.parse() ?

From: Jim McNamara<ma...@yahoo.com>
Sent: Saturday, June 18, 2022 5:19 PM
To: users@royale.apache.org<ma...@royale.apache.org>
Subject: json input parser won't parse regular array or indexed array: please help

Hi all-

I am stuck on my php_amf3 remoting code.

The offending line is something like this (from memory)

var ji:JSONInputParser;

input1.text = ji.parseItems('["foo", "bar"]').length.toString();

input1.text= ji.parseItems(' { "foo" : "bar" }').length.toString();

one is like an associative array and the other is like index in json format.

They won't print out in my text box. I'd really like the associative one to  work because that is what php_amf3 needs. If we can get this to work, I am quite certain that php_amf3 will work with arrays.

Please make a suggestion or confirm it is broken, and if so, I will do a bug report!

thanks