All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core_functions_json.json.pure Maven / Gradle / Ivy

The newest version!
// Copyright 2020 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import meta::json::*;

native function meta::json::escape(string:String[1]):String[1];

native function meta::json::parseJSON(string:String[1]):meta::json::JSONElement[1];

native function meta::json::fromJson(string:String[1], clazz:Class[1], config:JSONDeserializationConfig[1]):T[1];

native function meta::json::fromJsonDeprecated(string:String[1], clazz:Class[1], config:JSONDeserializationConfig[1]):T[1];

native function meta::json::toJsonBeta(instance: Any[*], config: JSONSerializationConfig[1]):String[1];

// This function checks that 2 JSON strings represent semantically same object when deserialized despite having
// different order of key-value pairs because of JSON objects being unordered sets of key/value pairs
native function meta::pure::functions::boolean::equalJsonStrings(left:String[1], right:String[1]):Boolean[1];

// JSON model
Class meta::json::JSONElement
{
}

Class meta::json::JSONBoolean extends JSONElement
{
    <> value : Boolean[1];
}

Class meta::json::JSONString extends JSONElement
{
    <> value : String[1];
}

Class meta::json::JSONNumber extends JSONElement
{
    <> value : Number[1];
}

Class meta::json::JSONNull extends JSONElement
{
    <> value : Nil[0];
}

Class meta::json::JSONArray extends JSONElement
{
    <> values : JSONElement[*];
}

Class meta::json::JSONObject extends JSONElement
{
    <> keyValuePairs : JSONKeyValue[*];
}

Class meta::json::JSONKeyValue
{
    <> key : JSONString[1];
    <> value : JSONElement[1];
}

Class meta::json::JSONConfig
{
    typeKeyName : String[1];
    typeLookup : Pair[*];
}

Class meta::json::JSONDeserializationConfig extends JSONConfig
{
    retainTypeField: Boolean[0..1];
    failOnUnknownProperties : Boolean[1];
    constraintsHandler: ConstraintsOverride[0..1];
}

Class meta::json::JSONSerializationConfig extends JSONConfig
{
    includeType: Boolean[0..1];
    fullyQualifiedTypePath: Boolean[0..1];
    //This only allows serializing 0 argument qualified properties
    serializeQualifiedProperties: Boolean[0..1];
    dateTimeFormat: String[0..1];
    serializePackageableElementName: Boolean[0..1];
    removePropertiesWithEmptyValues: Boolean[0..1];
    serializeMultiplicityAsNumber: Boolean[0..1];
    encryptionKey: String[0..1];
    encryptionStereotypes: Stereotype[*];
    decryptionKey: String[0..1];
    decryptionStereotypes: Stereotype[*];
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy