Jump to content

JSON: Difference between revisions

597 bytes added ,  3 years ago
m
Adds ColdFusion JSON example
m (→‎{{header|Tailspin}}: readability tweaks)
m (Adds ColdFusion JSON example)
Line 876:
console.log json_string
console.log json_obj
</lang>
 
=={{header|ColdFusion}}==
<lang coldfusion>
<!--- Create sample JSON structure --->
<cfset json = {
string: "Hello",
number: 42,
arrayOfNumbers: [1, 2, 3, 4],
arrayOfStrings: ["One", "Two", "Three", "Four"],
arrayOfAnything: [1, "One", [1, "One"], { one: 1 }],
object: {
key: "value"
}
} />
 
<!--- Convert to JSON string --->
<cfset jsonSerialized = serializeJSON(json) />
<!--- Convert back to ColdFusion --->
<cfset jsonDeserialized = deserializeJSON(jsonSerialized) />
 
<!--- Output examples --->
<cfdump var="#jsonSerialized#" />
<cfdump var="#jsonDeserialized#" />
</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.