/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomEnergyMixSerializer">A delegate to serialize custom hours JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <EnergyMix> CustomEnergyMixSerializer = null) { var JSON = JSONObject.Create( new JProperty("is_green_energy", IsGreenEnergy), EnergySources.SafeAny() ? new JProperty("energy_sources", new JArray(EnergySources.Select(energysource => energysource.ToJSON()))) : null, EnvironmentalImpacts.SafeAny() ? new JProperty("environ_impact", new JArray(EnvironmentalImpacts.Select(environmentalimpact => environmentalimpact.ToJSON()))) : null, SupplierName.IsNotNullOrEmpty() ? new JProperty("supplier_name", SupplierName) : null, EnergyProductName.IsNotNullOrEmpty() ? new JProperty("energy_product_name", EnergyProductName) : null ); return(CustomEnergyMixSerializer != null ? CustomEnergyMixSerializer(this, JSON) : JSON); }
/// <summary> /// Return a JSON representation of this object. /// </summary> public JObject ToJSON() { return(JSONObject.Create(new JProperty("is_green_energy", this.IsGreenEnergy), new JProperty("energy_sources", new JArray( EnergySources.SafeSelect(energysource => energysource.ToJSON()) )), new JProperty("environ_impact", new JArray( EnvironmentalImpacts.Select(environmentalimpact => environmentalimpact.ToJSON()) )), new JProperty("supplier_name", SupplierName), new JProperty("energy_product_name", EnergyProductName) )); }