Example #1
0
        /// <summary>
        /// This method deserializes the JSON data into a Field258 object. </summary>
        /// <param name="json"> JSON structure including tuples with label and value for all field components </param>
        /// <returns> a new field instance with the JSON data parsed into field components or an empty field id the JSON is invalid
        /// @since 7.10.3 </returns>
        /// <seealso cref= Field#fromJson(String) </seealso>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static Field258 fromJson(final String json)
        public static Field258 fromJson(string json)
        {
            Field258   field      = new Field258();
            JsonParser parser     = new JsonParser();
            JsonObject jsonObject = (JsonObject)parser.parse(json);

            if (jsonObject.get("lTAddress") != null)
            {
                field.setComponent1(jsonObject.get("lTAddress").AsString);
            }
            if (jsonObject.get("sessionNumber") != null)
            {
                field.setComponent2(jsonObject.get("sessionNumber").AsString);
            }
            if (jsonObject.get("messageType") != null)
            {
                field.Component3 = jsonObject.get("messageType").AsString;
            }
            if (jsonObject.get("date") != null)
            {
                field.setComponent4(jsonObject.get("date").AsString);
            }
            if (jsonObject.get("startTime") != null)
            {
                field.setComponent5(jsonObject.get("startTime").AsString);
            }
            if (jsonObject.get("endTime") != null)
            {
                field.setComponent6(jsonObject.get("endTime").AsString);
            }
            return(field);
        }
Example #2
0
        /// <summary>
        /// Copy constructor.<br>
        /// Initializes the components list with a deep copy of the source components list. </summary>
        /// <param name="source"> a field instance to copy
        /// @since 7.7 </param>
        public static Field258 newInstance(Field258 source)
        {
            Field258 cp = new Field258();

            cp.Components = new List <>(source.Components);
            return(cp);
        }