¡Caminando hacia el éxito!

Aprende en Comunidad

Avalados por :

New JSON Parsing Features in SAP Cloud Application Studio (SAP ByD and C4C) for Partners

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 11 Vistas
0
Cargando...
Hello Everyone,

The much-awaited JSON parse feature in SAP Cloud Application Studio (for SAP ByD and C4C) is here. Partners can now parse JSON using ABSL.

To parse JSON in ABSL, we faced a lot of difficulties and used string manipulation functions. But now we can use the new libraries to parse JSON format without any difficulties.

In version 2005 of the SAP Cloud Applications Studio, the following Reuse Library functions are new to JSON:


  1. Json.IsValidJson(json_string) : Returns true for valid JSON




  2. Json.GetArrayLength(keys, json_string) : Returns the total array length for the keys passed.



  3. Json.ParseKeyValues(keys, json_string) : Parses the JSON and provides value for the given keys.


To use this library and its functions, you must import the AP.PDI.Utilities namespace in ABSL script.

Sample JSON Format:




1. Validation JSON format


This function allows you to check if the JSON string is valid or not. The output is a boolean value where True indicates valid JSON string and False indicates Invalid.

Syntax:
Json.IsValidJson(json_string)



Sample Code:
import ABSL;
import AP.PDI.Utilities;

var JsonString = "{\"d\": {\"results\": [{ \"__metadata\": { \"type\": \"EmployeeDetails.Employee\" }, \"UserID\": \"E12012\",\"RoleCode\": \"35\"}]}}";
var Result = Json.IsValidJson(JsonString);


2. Parse JSON KeyValues


This function allows us to get values for the desired key present in the JSON string. We can parse JSON using Json. ParseKeyValues() function.

The following parameters need to be filled:


  • KeysTable : Table consisting of keys for which value is required.




  • JsonS tring : JSON string consisting the keys passed




After executing the API, the function returns the following parameter in the resulting structure.


Result : A table consisting of the following columns:
Pinterest
Telegram
Linkedin
Whatsapp

Sin respuestas

No hay respuestas para mostrar No hay respuestas para mostrar Se el primero en responder

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?