我正在尝试构建一个程序,在该程序中,我通过公司为其软件提供的客户端使用API。
这里是link。
尽管这样做确实使人们更容易建立连接并通过其嵌入式方法进行呼叫,但是一旦收到数据,我将很难处理数据。
[注意:我知道向所有人提供客户背景以及我如何进行通话是没有意义的,但是我认为一个人很难一眼了解发生的事情如果我什至没有提供客户端后面的连接情况或数据库的外观。]
以前,我尝试过在进行这样的调用后直接操作数据(下面的链接),但是我意识到这对我来说太困难了,因为我仍然对C#不满意,并且很难弄乱结果(对象)作为dynamic []值。
因此,我认为最好是采用将数据作为对象进行获取,序列化,将其转换为(json)并将其映射到属性的途径。我相信,一旦这样做,就应该更容易操作数据,因为我将有更轻松的时间将数据转换为单个值,列表等。但是,在这点上,我很难连接点码。
这是我到目前为止所拥有的。
我只对结果的EntryID,NameFirst和NameLast感兴趣,但是在此过程中,我确实发现自己正在利用该表其他字段和其他字段中的信息。如果有人可以帮助我建立从结果到这些属性的联系,我将不胜感激。这将是我尝试使用此API数据构建的应用程序中的重要一步。
谢谢!
属性类Link
JsonData处理器Link
呼叫Link的JSON结果
using System;
using [Custom]Api;
using Newtonsoft.Json;
namespace testing2
{
public class Program
{
public static void Main(string[] args)
{
[CustomApi]Client connection = new [CustomApi]Client("BaseURL",
"Username", "Password");
var value =
connection.Select("Entry",Criteria.Equals("NameLast","Rincon Recio"));
string results = JsonConvert.SerializeObject(value);
///not sure if making results as string is the right call to begin
this
//[Syntax where I tell results to match properties of Class 1]
//[Create list of EntryID, NameFirst, NameLast]
//[Display list in listbox]
Console.WriteLine(results);
Console.ReadLine();
}
}
}
答案 0 :(得分:1)
不,JsonConvert.SerializeObject(value)
不会有所作为。
尝试将values
反序列化为Class1
的数组。
像这样
var realResult = JsonConvert.DeserializeObject<Class1[]>(values);