我在控制器中生成一个 JSON 列表,当我尝试使用 Jsonview 将其传递给视图时,它会使用我的 JSON 结果添加其他属性。我想要这个结果
{"id":"xyz","parent":"#","text":"folder"}
但它显示
[{"Id":".","Type":null,"Default":null,"Properties":{},"Items":[],"ItemsPositionValidation":false,"Required":[],"AllOf":[],"AnyOf":[],"OneOf":[],"Not":null,"Enum":[],"UniqueItems":false,"MinimumLength":null,"MaximumLength":null,"Minimum":null,"Maximum":null,"ExclusiveMinimum":false,"ExclusiveMaximum":false,"MinimumItems":null,"MaximumItems":null,"MinimumProperties":null,"MaximumProperties":null,"ExtensionData":{"parent":[],"text":[]},"Title":null,"Description":null,"MultipleOf":null,"Pattern":null,"Dependencies":{},"AdditionalProperties":null,"PatternProperties":{},"AllowAdditionalProperties":true,"AdditionalItems":null,"AllowAdditionalItems":true,"Format":null}
public ActionResult list()
{
Uri firstUrl = new Uri("ftp.xyz.com");
List<JSchema> tst = DisplayList(firstUrl);
return View(tst);
}
public static List<JSchema> DisplayList(Uri serverUri)
{
List<String> tet = new List<String>();
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(serverUri);
Request.Credentials = new NetworkCredential("username", "password");
Request.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();
Stream ResponseStream = Response.GetResponseStream();
StreamReader Reader = new StreamReader(ResponseStream);
//JSchema sch = JSchema.Parse(jsonsch);
int counter = 0;
while (!Reader.EndOfStream)//Read file name
{
string temp = Reader.ReadLine();
tet.Add( @"{'id' : '" + temp + "', 'parent' : '#','text' :'" + temp + "' }");
counter++;
}// end while
List<JSchema> js = new List<JSchema>();
for (int i =0; i<counter ; i++ )
{
js.Add ( JSchema.Parse(tet[i]));
}
Response.Close();
ResponseStream.Close();
Reader.Close();
return js;
}// end display list