Rate This Document
Findability
Accuracy
Completeness
Readability

Gson::toJson(Object* obj)

Function Usage

Serializes an object into a string if the object is a class that can be processed by JSON (JsonElement, GsonObject, Map, and Configuration), or otherwise, returns a null pointer.

Function Syntax

String *Gson::toJson(Object* obj);

Parameters

Parameter

Description

Value Range

Input/Output

obj

Pointer to the object to be serialized.

Not null

Input

Return Value

  • Success: serialization result of the object.
  • Failure: a null pointer if the obj pointer is null or the object is an unsupported class of JSON.

You must use delete to release the returned pointer to the String structure.