Here’s where I’ve been:
I made a PHP client call via soap to retrieve an array of data,
I successfully receieved and converted my array to JSON via json_encode,
I then echoed it back to my page.
Here’s where I am:
I get back my array in this format…
{“MethodName”:”ID,11|1|Item1,22|2|Item2,33|3|Item3″}
Here’s where I want to be:
Using Javascript or JSON, my objective is to end up with 2 variables (Method & ID) and one variable array (ItemList)…ie
- var Method = “MethodName”;
- var ID = “ID”;
- var ItemList = [’11|1|Item1′ , ’22|2|Item2′ , ’33|3|Item3′];
I have the front and back of my script working, but I’m stumped on the array(string)…
How do I parse, divide, or split this result?
i’d probably try a regex first thing. something like
the parentheses will separate the matches.
match[0]will be the whole thing,match[1]will be the method name,match[2]will be the id,match[3]will be the remainder as a string. you can then doto get the array for the 3rd part.