JSON-Funktionen im Jitterbit Integration Studio
Einführung
JavaScript-Objektnotation (JSON)-Funktionen ermöglichen die Bearbeitung von Daten im JSON-Format. Weitere Informationen zu JSON finden Sie unter IETF RFC 8259: Das JavaScript Object Notation (JSON)-Datenaustauschformat.
GetJSONString
Erklärung
string GetJSONString(string json_string, string path)
Syntax
GetJSONString(<json_string>, <path>)
Erforderliche Parameter
json_string
: Ein JSON-Objektstring zum Parsen der Daten.path
: Ein Pfad, der den Speicherort der Daten im JSON-Objektstring darstellt.
Beschreibung
Ruft Daten aus einem JSON-Objektstring über den angegebenen Pfad ab.
Wichtig
Diese Funktion erfordert Agent-Version 11.28 oder höher.
Beispiele
// Define the JSON object string:
json_string = '{ "company":`[{ "Name": "Jitterbit", "Produkt": [{ "Typ": "iPaaS", "Name": "Jitterbit iPaaS" },{ "Typ": "EDI", "Name": "Jitterbit EDI" }] `}] }';
GetJSONString(json_string, "/company/[0]/product/[1]/name");
// Returns "Jitterbit EDI"
GetJSONString(json_string, "/company/[0]/product");
// Returns '[{"type":"iPaaS","name":"Jitterbit iPaaS"},{"type":"EDI","name":"Jitterbit EDI"}]'
JSONParser
Erklärung
dictionary JSONParser(string json_string)
Syntax
JSONParser(<json_string>)
Erforderliche Parameter
json_string
: Ein JSON-Objektstring, der in ein JSON-Objekt konvertiert werden soll.
Beschreibung
Konvertiert einen JSON-Objektstring in ein JSON-Objekt.
Wichtig
Diese Funktion erfordert Agent-Version 11.29 oder höher.
Beispiele
// Define the JSON object string:
json_string = '{ "company":`[{ "Name": "Jitterbit", "Produkt": [{ "Typ": "iPaaS", "Name": "Jitterbit iPaaS" },{ "Typ": "EDI", "Name": "Jitterbit EDI" }] `}] }';
// Convert the JSON object string into a JSON object:
json_object = JSONParser(json_string);
result = json_object["company"][0]["product"][1]["name"];
// Equals "Jitterbit EDI"
result = json_object["company"][0]["product"];
// Equals {"[name=>""Jitterbit iPaaS"",type=>""iPaaS""]","[name=>""Jitterbit EDI"",type=>""EDI""]"}
JSONStringify
Erklärung
string JSONStringify(dictionary json_object)
Syntax
JSONStringify(<json_object>)
Erforderliche Parameter
json_object
: Ein JSON-Objekt, das in einen JSON-Objektstring konvertiert werden soll.
Beschreibung
Konvertiert ein JSON-Objekt in einen JSON-Objektstring.
Wichtig
Diese Funktion erfordert Agent-Version 11.30 oder höher. Unterstützung für reservierte JSON-Zeichen wie "
Und \
Für die Verarbeitung von Nulldaten ist Agentenversion 11.45 oder höher erforderlich.
Beispiel
// Define the JSON object structure:
json_object = Dict();
json_object["company"][0] = Dict();
json_object["company"][0]["name"] = "Jitterbit";
json_object["company"][0]["product"][0] = Dict();
json_object["company"][0]["product"][0]["type"] = "iPaaS";
json_object["company"][0]["product"][0]["name"] = "Jitterbit iPaaS";
json_object["company"][0]["product"][0]["active"] = True;
json_object["company"][0]["product"][0]["internalID"] = 123;
json_object["company"][0]["product"][0]["description"] = 'Low-code integration solutions that deliver enterprise-grade performance.\nSecure, scalable, and AI-infused, Jitterbit iPaaS grows with your organization.\n"Request a free trial today!"';
json_object["company"][0]["product"][1] = Dict();
json_object["company"][0]["product"][1]["type"] = "EDI";
json_object["company"][0]["product"][1]["name"] = "Jitterbit EDI";
json_object["company"][0]["product"][1]["active"] = True;
json_object["company"][0]["product"][1]["internalID"] = 124;
json_object["company"][0]["product"][1]["description"] = null();
JSONStringify(json_object);
// Returns '{"company":[{"name":"Jitterbit", "product":[{"name":"Jitterbit iPaaS", "type":"iPaaS", "active":1, "internalID":123, "description":"Low-code integration solutions that deliver enterprise-grade performance.\\nSecure, scalable, and AI-infused, Jitterbit iPaaS grows with your organization.\\n\\"Request a free trial today!\\""},
{"name":"Jitterbit EDI", "type":"EDI", "active":1, "internalID":124, "description":null}]}]}'