Ansicht
Dokumentation

ABENABAP_ASJSON_CLASS_INSTANCES - ABAP ASJSON CLASS INSTANCES

ABENABAP_ASJSON_CLASS_INSTANCES - ABAP ASJSON CLASS INSTANCES

ROGBILLS - Synchronize billing plans   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

- Instances of Classes

To transform classes to JSON using the statement CALL TRANSFORMATION or to create classes from JSON data, their classes must implement the interface IF_SERIALIZABLE_OBJECT. The instance of a class (object) is represented as an object component of the object %heap as follows:

"key":{ "%type":"class",
        "%val":{ "part":{ "%classVersion":"...",
                          "name":...
                          ...
                        }
                 ...
               }
      }

The name key is the key used to reference the object. The value of key is itself an object whose object components represent the class and the attributes of the referenced ABAP object.

  • The character-like value class of the component %TYPE specifies the class of the object. The same applies to class as to the element name class in asXML representation. In asJSON, the namespace that specifies where the class is defined in asXML is resolved before the class name.
  • The component %VAL represents the attribute values of the object. The value of %VAL is itself an object. The components part are objects that contain the values of the instance attributes of individual object parts. The same applies to the object parts and their names part as to the subelements part> in asXML representation.
  • The components of an object part part represent the values of the instance attributes of the objects in their canonical representation under their names. The same applies to the names as to the corresponding elements in asXML representation. Static attributes are ignored.
  • An optional component, %classVersion, of an object part, part, contains the version of the class of the object part in character-like representation. The same applies to the version of the class as to the attribute classVersion in asXML representation.

The tag interface IF_SERIALIZABLE_OBJECT has the same meaning for JSON as for asXML. This means it defines which attributes of a class are serialized. In addition, helper methods can be implemented that adjust behavior (see the example).

asJSON for Object References






Fill RESBD Structure from EBP Component Structure   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 4925 Date: 20240419 Time: 080359     sap01-206 ( 63 ms )