using System.Collections.Generic;
using System.ComponentModel;
using Newtonsoft.Json.Serialization;
public static void Main()
""description"": ""Frankfurt am Main, Deutschland"",
""place_id"": ""ChIJxZZwR28JvUcRAMawKVBDIgQ"",
""description"": ""Frankfurt (Oder), Deutschland"",
""place_id"": ""ChIJb_u1AiqYB0cRwDteW0YgIQQ"",
""description"": ""Frankfurt Hahn Flughafen (HHN), Lautzenhausen, Deutschland"",
""place_id"": ""ChIJX3W0JgQYvkcRWBxGlm6csj0"",
var objs = JsonConvert.DeserializeObject<ResponseWrapper>(input);
var jsonResolver = new IgnorePropertiesContractResolver();
var jsonSettings = new JsonSerializerSettings() {
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = jsonResolver
var output = JsonConvert.SerializeObject(objs, jsonSettings);
Console.WriteLine(output);
public class ResponseWrapper
[JsonProperty("success")]
public bool Success { get;set; }
[JsonProperty("message")]
public string Message { get;set; }
[Obsolete("This field should not be used anymore, please use Message instead", true)]
Success = value.Equals("OK", StringComparison.OrdinalIgnoreCase);
public Prediction[] Data { get;set; }
[Obsolete("This field should not be used anymore, please use Data instead", true)]
public Prediction[] Predictions
public string description { get; set; }
public string place_id { get; set; }
public class IgnorePropertiesContractResolver : DefaultContractResolver
protected readonly Dictionary<Type, HashSet<string>> Ignores;
public IgnorePropertiesContractResolver()
this.Ignores = new Dictionary<Type, HashSet<string>>();
this.IgnoreObsoleteProperties = true;
public bool IgnoreObsoleteProperties { get;set; }
public void Ignore(Type type, params string[] propertyName) {
if (!this.Ignores.ContainsKey(type)) this.Ignores[type] = new HashSet<string>();
foreach (var prop in propertyName) {
this.Ignores[type].Add(prop);
public bool IsIgnored(Type type, string propertyName) {
if (IgnoreObsoleteProperties)
var prop = type.GetProperty(propertyName);
if (prop != null && prop.GetCustomAttributes(typeof(ObsoleteAttribute), false).Any())
if (!this.Ignores.ContainsKey(type)) return false;
if (this.Ignores[type].Count == 0) return true;
return this.Ignores[type].Contains(propertyName);
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
if (this.IsIgnored(property.DeclaringType, property.PropertyName)) {
property.ShouldSerialize = instance => { return false; };