예제 #1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomOpeningTimesSerializer">A delegate to serialize custom opening time JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <OpeningTime> CustomOpeningTimesSerializer = null)
        {
            var JSON = JSONObject.Create(

                Periods.SafeAny()
                               ? new JProperty("Period", new JArray(Periods.Select(period => period.ToJSON())))
                               : null,

                new JProperty("on", On.AsString()),

                UnstructuredText.IsNotNullOrEmpty()
                               ? new JProperty("unstructuredOpeningTime", UnstructuredText)
                               : null

                );

            return(CustomOpeningTimesSerializer != null
                       ? CustomOpeningTimesSerializer(this, JSON)
                       : JSON);
        }