我有这样的课
public class Sample
{
public string A { get; set; }
public int B { get; set; }
}
var sampleValues = new List<Sample>(){
new Sample(){ A = "a1", B = 1 },
new Sample(){ A = "a2", B = 2 },
new Sample(){ A = "a3", B = 3 },
new Sample(){ A = "a4", B = 4 },
.....
new Sample(){ A ="a30", B = 30}
};
Run Code Online (Sandbox Code Playgroud)
有没有简单的方法用30个连续值初始化它,如图所示?
我正在尝试使用 Rest API 获取 firestore 文档,它以以下格式返回数据
{"fields":{"list1":{"arrayValue":{"values":[{"stringValue":"item1"},{"stringValue":"item2"}]}}}}
Run Code Online (Sandbox Code Playgroud)
如何将上述文档转换为如下所示的纯 JavaScript 对象,并在进行更新调用之前将其转换回 Firestore 文档
{"list1":["item1","item2"]}
Run Code Online (Sandbox Code Playgroud)
编辑:更多信息
json sample1 由 Firestore api 返回并包含所有数据类型信息
json sample2 是我没有类型信息的实际数据。
我的问题是 firestore RestApi get 调用以 json sample1 格式返回响应。我想更新 api 响应中的一些信息并将更新后的值发送回 firestore db。但是由于响应中的所有类型信息,我无法在必要时更新值。所以我试图找到是否有办法将 api 响应转换为 json sample2。
使用的 API 网址:https : //firestore.googleapis.com/v1/projects/projects/ {project_id}/databases/{database_id}/documents/{document_path}