Re; JSON & Multi value data

3 views
Skip to first unread message

ChrisB

unread,
Aug 20, 2013, 4:38:11 PM8/20/13
to InterSy...@googlegroups.com
hi,
 
I am dealing with a JSON string which is created by PICK as per example below which contains a multi value  array (the hotel address). Does anyone know how to extract the address using javascript. I currently use the function JSON.parse() to extract the data but cannot seem to extract the multi value fields correctly.  I have used the function Address.split(',') to obtain address fields separately  but it doesnot work. Any help would be much appreciated. Thanks Chris
 
{                                                                              
"FileId":"HIL",                                                                
"Name":"HILTON HOTEL HYDE PARK",                                               
"Address":["101 HYDE PARK ROAD,HYDE PARK,WEST LONDON,LONDON,UK,"],             
"PostCode":"SW1 1ZU"
}

Rich Taylor

unread,
Aug 21, 2013, 1:56:13 PM8/21/13
to InterSy...@googlegroups.com

Chris,

 

I am happy to help.   See the example below.  JSON is simply form of a javascript array so you can use javascript array syntax to access it.  I did notice a problem however.  The JSON is not being generated properly to form an array structure.  Each value of the Address array must be quoted separately and separated by comas.  This is corrected in the example below.  This example simply takes the JSON you sent (corrected) and loads a textarea control whose id is ‘display’ on my ZEN page.

 

ClientMethod LoadText() [ Language = javascript ]
{
            var json {

"FileId":"HIL",
"Name":"HILTON HOTEL HYDE PARK",

"Address":["101 HYDE PARK ROAD","HYDE PARK","WEST LONDON,LONDON,UK,"],
"PostCode":"SW1 1ZU"
};

zen("display").setValue(json.Address[1] "\n" json.Address[2]);
}

 

Richard S Taylor
Sales Engineer
InterSystems Corporation
Office: 443-340-8614
FAX: 440-815-5805

Advanced Software technologies for Breakthrough applications 

--
You received this message because you are subscribed to the Google Groups "InterSystems: MV Community" group.
---
You received this message because you are subscribed to the Google Groups "InterSystems: MV Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to InterSystems-...@googlegroups.com.
To post to this group, send email to InterSy...@googlegroups.com.
Visit this group at http://groups.google.com/group/InterSystems-MV.
For more options, visit https://groups.google.com/groups/opt_out.

Chris B

unread,
Aug 21, 2013, 3:53:32 PM8/21/13
to InterSy...@googlegroups.com
Hi Richard,
Many thanks for your response which was a great help and much appreciated,
ChrisB
checked for viruses and spam by CanIt.
http://www.canit.3d.net.uk/
--
image001.jpg
Reply all
Reply to author
Forward
0 new messages