Informatica ActiveVOS
- Informatica ActiveVOS 9.2.4.6
- All Products
<contactInfo />
{ "contactInfo" : {} }
<contactInfo type="home" default="true" />
{ "contactInfo" : { "type" : "home", "default": "true" } }
var doc = { "contactInfo" : { "type": "home", "default": "true" } }; // type attribute is accessed via doc.contactInfo["type"] // or doc.contactInfo.type. alert("contact information type: " + doc.contactInfo.type);
<contactInfo type="home" default="true" > <phone /> </contactInfo>
{ "contactInfo" : { "type" : "home", "default": "true", "phone" : {} } }
<contactInfo type="home" default="true" > <phone type="voice">203-555-1212</phone> </contactInfo>
{ "contactInfo" : { "type" : "home", "default": "true", "phone" : { "type" : "voice", "$t" : "203-555-1212" } } }
// JavaScript: var doc = { .... }; // define json // the phone number is doc.contactInfo.phone.$t alert("phone number: " + doc.contactInfo.phone.$t);
<contactInfo type="home" default="true" > <phone type="voice">203-555-1212</phone> <phone type="fax">203-555-1213</phone> </contactInfo>
{ "contactInfo" : { "type" : "home", "default": "true", "phone" : [ { "type" : "voice", "$t" : "203-555-1212" }, { "type" : "fax", "$t" : "203-555-1213" } ] } }
// JavaScript: // Access phone via array index: doc.contactInfo.phone[0].$t var i; for (i=0; i < doc.contactInfo.phone.length; i++) { alert( "phone " + i + " = " + doc.contactInfo.phone[i].$t); }
<p:person xmlns:p="urn:ns:person"> <p:firstName>John</p:firstName> <p:lastName>Smith</p:lastName> <c:contactInfo xmlns:c="urn:ns:contactinfo" type="home" default="true" > <c:phone type="voice">203-555-1212</c:phone> <c:phone type="fax">203-555-1213</c:phone> <email>jsmith@example.com</email>Happy </c:contactInfo> <photo>http://example.com/jsmith/profile.png</photo> </p:person>
{ "p$person" : { "xmlns$p" : "urn:ns:person", "p$firstName" : { "$t" : "John" }, "p$lastName" : { "$t" : "Smith" }, "c$contactInfo" : { "xmlns$c" : "urn:ns:contactinfo", "default" : "true", "type" : "home", "c$phone" : [ { "type" : "voice", "$t" : "203-555-1212" }, { "type" : "fax", "$t" : "203-555-1213" } ], "email" : { "$t" : "jsmith@example.com" } }, "photo" : { "$t" : "http://example.com/jsmith/profile.png" } } }
// JavaScript: var doc = { ... }; // JSON representation of person. // first Name: /p:person/p:firstName/text() alert("firstName =" + doc.p$person.p$firstName.$t); // photo /p:person/photo/text() alert("photo =" + doc.p$person.photo.$t); // email /p:person/c:contactInfo/email/text() alert("email =" + doc.p$person.c$contactInfo.email.$t); var i; for (i=0; i < doc.p$person.c$contactInfo.c$phone.length; i++) { alert( "phone " + i + "=" + doc.p$person.c$contactInfo.c$phone[i].$t); }
<person xmlns="urn:ns:person"> <firstName>John</firstName> <lastName>Smith</lastName> <contactInfo xmlns="urn:ns:contactinfo" type="home" default="true" > <phone type="voice">203-555-1212</phone> <phone type="fax">203-555-1213</phone> <email xmlns="">jsmith@example.com</email> </contactInfo> <photo xmlns="">http://example.com/jsmith/profile.png</photo> </person>
{ "person" : { "xmlns" : "urn:ns:person", "firstName" : { "$t" : "John" }, "lastName" : { "$t" : "Smith" }, "contactInfo" : { "xmlns" : "urn:ns:contactinfo", "default" : "true", "type" : "home", "phone" : [ { "type" : "voice", "$t" : "203-555-1212" }, { "type" : "fax", "$t" : "203-555-1213" } ], "email" : { "xmlns" : "", "$t" : "jsmith@example.com" } }, "photo" : { "xmlns" : "", "$t" : "http://example.com/jsmith/profile.png" } } }
// JavaScript: var doc = { ... }; // JSON representation of person using default namespace (and no prefixes). // first Name: alert("firstName =" + doc.person.firstName.$t); // (compare above to prefixed version doc.p$person.p$firstName.$t) // photo alert("photo =" + doc.person.photo.$t); // (compare to prefixed version doc.p$person.photo.$t) // email /p:person/c:contactInfo/email/text() alert("email =" + doc.person.contactInfo.email.$t); // (compare to doc.p$person.c$contactInfo.email.$t) var i; for (i=0; i < doc.person.contactInfo.phone.length; i++) { alert( "phone " + i + "=" + doc.person.contactInfo.phone[i].$t); }