I have to deserialize two json strings to the obeject, in these two json strings there are similar attributes that cannot be ignored. So the properties in converted C # object must also remain. these two strings are the parameters in Json String of two Api Call. First API makes a folder and second API adds a file to this created folder, so the parameters and properties of json that are similar cannot be ignored and excluded .. I have put two classes that are converted from the json string into the main program The two are in a namespace, if the name of one of these namespace changes, there is a conflict in the code in the place where the second string is deserialized :
List<fileinsert> example2 = JsonConvert.DeserializeObject<List<fileinsert>>(fileinsert.Content);
under fileinsert there is a red line: "CS0118:" fileinsert "is" Variable "but is used like" Type ".
Here is the deserialed object from the second Json string:
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Text.Json;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Text.Json.Serialization;
namespace Api2
{
public class Datum
{
public string internalName { get; set; }
public string value { get; set; }
}
public class Typ
{
public string internalName { get; set; }
public string value { get; set; }
}
public class Fields
{
public Datum Datum { get; set; }
public Typ Typ { get; set; }
}
public class fileinsert
{
public string cabinet { get; set; }
public string name { get; set; }
public string objectTypeId { get; set; }
public Fields fields { get; set; }
}
}
How do I have to proceed so that both objects are desrialized and still the similar attributes are retained and all remain in one namespace.
I thank you in advance
here is the code and also the converted code from First Json String :
<pre>List<folderinsert>example1= JsonConvert.DeserializeObject<List<folderinsert>>(folderinsert.Content);
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Text.Json;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Text.Json.Serialization;
namespace Api1
{
public class Datum
{
public string value { get; set; }
}
public class Fields
{
public Datum Datum { get; set; }
}
public class folderinsert
{
public string cabinet { get; set; }
public string name { get; set; }
public string objectTypeId { get; set; }
public Fields fields { get; set; }
}
}
What I have tried:
I tried to change the namespaces