public static JObject ToJSON(this SmartCityProxy SmartCity, Boolean Embedded = false, Boolean ExpandChargingRoamingNetworkId = false, Boolean ExpandChargingPoolIds = false, Boolean ExpandChargingStationIds = false, Boolean ExpandEVSEIds = false) => SmartCity != null ? JSONObject.Create( new JProperty("id", SmartCity.Id.ToString()), Embedded ?null : ExpandChargingRoamingNetworkId ?new JProperty("roamingNetwork", SmartCity.RoamingNetwork.ToJSON()) : new JProperty("roamingNetworkId", SmartCity.RoamingNetwork.Id.ToString()), new JProperty("name", SmartCity.Name.ToJSON()), new JProperty("description", SmartCity.Description.ToJSON()), // Address // LogoURI // API - RobotKeys, Endpoints, DNS SRV // MainKeys SmartCity.Logo.IsNotNullOrEmpty() ?new JProperty("logos", JSONArray.Create( JSONObject.Create( new JProperty("uri", SmartCity.Logo), new JProperty("description", I18NString.Empty.ToJSON()) ) )) : null, SmartCity.Homepage.IsNotNullOrEmpty() ?new JProperty("homepage", SmartCity.Homepage) : null, SmartCity.HotlinePhoneNumber.IsNotNullOrEmpty() ?new JProperty("hotline", SmartCity.HotlinePhoneNumber) : null, SmartCity.DataLicenses.Any() ?new JProperty("dataLicenses", new JArray(SmartCity.DataLicenses.Select(license => license.ToJSON()))) : null //new JProperty("chargingPools", ExpandChargingPoolIds // ? new JArray(SmartCity.ChargingPools. ToJSON(Embedded: true)) // : new JArray(SmartCity.ChargingPoolIds. Select(id => id.ToString()))), //new JProperty("chargingStations", ExpandChargingStationIds // ? new JArray(SmartCity.ChargingStations. ToJSON(Embedded: true)) // : new JArray(SmartCity.ChargingStationIds.Select(id => id.ToString()))), //new JProperty("evses", ExpandEVSEIds // ? new JArray(SmartCity.EVSEs. ToJSON(Embedded: true)) // : new JArray(SmartCity.EVSEIds. Select(id => id.ToString()))) ) : null;
public static JProperty ToJSON(this SmartCityProxy SmartCity, String JPropertyKey) => SmartCity != null ? new JProperty(JPropertyKey, SmartCity.ToJSON()) : null;