Serialize()
Opposite of evaluate, this function serializes all cfml objects and all serializable Java objects. Can also serialize Components.
As objects can be serialized, this is not safe and cannot be trusted like JSON.
Avoid using serialize/evaluate with untrusted end user content, SerializeJSON() / DeserializeJSON() is a safe alternative.
Serialize( object=any );
Returns: String
| Argument | Description |
|---|---|
|
object
any,
required
|
edit
An object to be serialized. |
Examples
editstruct_object = { name = "Joe", email = "joe@example.com" };
array_object = ["John Doe", { name = "Joe", email = "joe@example.com" }, 1000];
java_object = createObject("java", "java.lang.StringBuffer").init("");
dump(Serialize(struct_object)); // {'name':'Joe','email':'joe@example.com'}
dump(Serialize(array_object)); // ['John Doe',{'name':'Joe','email':'joe@example.com'},1000]
dump(Serialize(java_object));
See also
- Java
- Diagnosing struct iteration-order regressions on 7.1 with `lucee.concurrent.map.impl=legacy`
- DeserializeJSON()
- Evaluate()
- SerializeJSON()
- UnserializeJava()
- Serialize all types of data by using serialize(data)
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)