Titanium - Json对象返回一个空数组

时间:2014-12-24 12:05:05

标签: javascript json titanium

我的WEC webservice返回一个JSON对象,我想在我的Titanium应用程序中使用它,但问题是,JSON对象中有数组,我可以在控制台中看到它们但是当我试图通过提供访问时索引,它不起作用。

示例

{
    "GetDoctorFavoriteTestResult": "{\"CountryList\":null,\"AddressDetails\":null,\"CollectionAddressDetails\":null,\"CourierAddressDetails\":null,\"labAddressDetails\":null,\"TestDetails\":[{\"TestID\":29,\"TestName\":\"CEA-Carcino Embryonic Antigen, serum\",\"Row\":0,\"LabID\":0,\"DoctorPatientMappingId\":0,\"PatientId\":0,\"TestDesc\":\"Colonic cancer marker.\\n\\nNote\\n1. This test is not recommended for cancer screening in the general population.\\n2. False negative / positive results are observed in patients receiving mouse monoclonal antibodies for diagnosis or therapy.\\n3. Patients with confirmed carcinoma may show normal pre-treatment CEA levels. Hence this assay, regardless of level, should not be interpreted as absolute evidence for presence or absence of malignant disease. The assay value should be used in conjunction with fi\",\"TestPrice\":0.0,\"BasePrice\":0.0,\"DiscountPrice\":0.0,\"Currency\":null,\"SampleAtHome\":false,\"IsActive\":false,\"LabName\":null,\"TestPerformedLabName\":null,\"Link\":null,\"TestResult\":null,\"UploadedTestFile\":null,\"PatientName\":null,\"TestRemarks\":null,\"ResultType\":null,\"TestFavouriteId\":0,\"CollectionPrice\":0.0,\"TotalPrice\":0.0,\"PaymentToECL\":0.0,\"PaymentFromECL\":0.0,\"ToBeListed\":true,\"OrderAmt\":0.0,\"AfterDiscountPrice\":0.0,\"CollectionType\":0,\"PreferedDate\":\"0001-01-01T00:00:00\",\"PreferedTime\":null,\"SpecialInstructions\":null,\"PaymentType\":0,\"PaymentTypeStatus\":null,\"PaymentStatus\":null,\"CourierAddressId\":0,\"CollectionAddressId\":0,\"OrderId\":0,\"OrderDetailId\":0,\"BookedDateTime\":\"0001-01-01T00:00:00\",\"ModifiedDate\":\"0001-01-01T00:00:00\",\"PreviousSlotDateTime\":null,\"CategoryID\":0,\"TestCode\":null,\"CPTCode\":null,\"Abbrevation\":\"CEA\",\"MethodID\":0,\"SampleTypeID\":0,\"SampleTypeDesc\":null,\"TempId\":0,\"Description\":null,\"TAT\":null,\"TestType\":0,\"SampleOptions\":null,\"IdCountry\":0,\"IdState\":0,\"IdCity\":0,\"MethodName\":null,\"CategoryName\":null,\"TestCondition\":null,\"HyperLink\":null,\"ReferenceValue\":null,\"Units\":null,\"ReportAttributes\":null,\"OrderStatus\":null,\"TestAvailableHome\":false,\"PathologistId\":0,\"PathologistName\":null,\"TechnicianName\":null,\"PathologistSign\":null,\"TechnicianSing\":null,\"EmailId\":null,\"LabEmailId\":null,\"SampleCollectedDate\":null,\"ReportUploadedDate\":null,\"IsExists\":false},{\"TestID\":73,\"TestName\":\"Family Finder + Y-DNA67\",\"Row\":0,\"LabID\":0,\"DoctorPatientMappingId\":0,\"PatientId\":0,\"TestDesc\":\"Family Finder + Y-DNA67\",\"TestPrice\":0.0,\"BasePrice\":0.0,\"DiscountPrice\":0.0,\"Currency\":null,\"SampleAtHome\":false,\"IsActive\":false,\"LabName\":null,\"TestPerformedLabName\":null,\"Link\":null,\"TestResult\":null,\"UploadedTestFile\":null,\"PatientName\":null,\"TestRemarks\":null,\"ResultType\":null,\"TestFavouriteId\":0,\"CollectionPrice\":0.0,\"TotalPrice\":0.0,\"PaymentToECL\":0.0,\"PaymentFromECL\":0.0,\"ToBeListed\":true,\"OrderAmt\":0.0,\"AfterDiscountPrice\":0.0,\"CollectionType\":0,\"PreferedDate\":\"0001-01-01T00:00:00\",\"PreferedTime\":null,\"SpecialInstructions\":null,\"PaymentType\":0,\"PaymentTypeStatus\":null,\"PaymentStatus\":null,\"CourierAddressId\":0,\"CollectionAddressId\":0,\"OrderId\":0,\"OrderDetailId\":0,\"BookedDateTime\":\"0001-01-01T00:00:00\",\"ModifiedDate\":\"0001-01-01T00:00:00\",\"PreviousSlotDateTime\":null,\"CategoryID\":0,\"TestCode\":null,\"CPTCode\":null,\"Abbrevation\":\"Family Finder + Y-DNA67\",\"MethodID\":0,\"SampleTypeID\":0,\"SampleTypeDesc\":null,\"TempId\":0,\"Description\":null,\"TAT\":null,\"TestType\":0,\"SampleOptions\":null,\"IdCountry\":0,\"IdState\":0,\"IdCity\":0,\"MethodName\":null,\"CategoryName\":null,\"TestCondition\":null,\"HyperLink\":null,\"ReferenceValue\":null,\"Units\":null,\"ReportAttributes\":null,\"OrderStatus\":null,\"TestAvailableHome\":false,\"PathologistId\":0,\"PathologistName\":null,\"TechnicianName\":null,\"PathologistSign\":null,\"TechnicianSing\":null,\"EmailId\":null,\"LabEmailId\":null,\"SampleCollectedDate\":null,\"ReportUploadedDate\":null,\"IsExists\":false},{\"TestID\":69,\"TestName\":\"Family Finder (For Both)\",\"Row\":0,\"LabID\":0,\"DoctorPatientMappingId\":0,\"PatientId\":0,\"TestDesc\":\"Family Finder (For Both)\",\"TestPrice\":0.0,\"BasePrice\":0.0,\"DiscountPrice\":0.0,\"Currency\":null,\"SampleAtHome\":false,\"IsActive\":false,\"LabName\":null,\"TestPerformedLabName\":null,\"Link\":null,\"TestResult\":null,\"UploadedTestFile\":null,\"PatientName\":null,\"TestRemarks\":null,\"ResultType\":null,\"TestFavouriteId\":0,\"CollectionPrice\":0.0,\"TotalPrice\":0.0,\"PaymentToECL\":0.0,\"PaymentFromECL\":0.0,\"ToBeListed\":true,\"OrderAmt\":0.0,\"AfterDiscountPrice\":0.0,\"CollectionType\":0,\"PreferedDate\":\"0001-01-01T00:00:00\",\"PreferedTime\":null,\"SpecialInstructions\":null,\"PaymentType\":0,\"PaymentTypeStatus\":null,\"PaymentStatus\":null,\"CourierAddressId\":0,\"CollectionAddressId\":0,\"OrderId\":0,\"OrderDetailId\":0,\"BookedDateTime\":\"0001-01-01T00:00:00\",\"ModifiedDate\":\"0001-01-01T00:00:00\",\"PreviousSlotDateTime\":null,\"CategoryID\":0,\"TestCode\":null,\"CPTCode\":null,\"Abbrevation\":\"Family Finder (For Both)\",\"MethodID\":0,\"SampleTypeID\":0,\"SampleTypeDesc\":null,\"TempId\":0,\"Description\":null,\"TAT\":null,\"TestType\":0,\"SampleOptions\":null,\"IdCountry\":0,\"IdState\":0,\"IdCity\":0,\"MethodName\":null,\"CategoryName\":null,\"TestCondition\":null,\"HyperLink\":null,\"ReferenceValue\":null,\"Units\":null,\"ReportAttributes\":null,\"OrderStatus\":null,\"TestAvailableHome\":false,\"PathologistId\":0,\"PathologistName\":null,\"TechnicianName\":null,\"PathologistSign\":null,\"TechnicianSing\":null,\"EmailId\":null,\"LabEmailId\":null,\"SampleCollectedDate\":null,\"ReportUploadedDate\":null,\"IsExists\":false}],\"ExistingMappedTest\":null,\"AllTestDetails\":null,\"CountryPrices\":null,\"PriceComponents\":null,\"OrderedTestDetails\":null,\"BookedSlots\":null,\"LabScheduleDetails\":null,\"ReturnValue\":0,\"ReturnMessage\":null,\"TotalRecords\":0,\"Rows\":0,\"IsActive\":false}"
}

在这里,我可以使用 JSON.parse 访问 GetDoctorFavoriteTestResult.CountryList ,但是当我试图获取数组时 GetDoctorFavoriteTestResult.TestDetails 它显示为空。

即使在浏览器中,Webservice仍然运行良好。

再次,我可以在Titanium控制台窗口中看到数组数据。

任何解决方案?

2 个答案:

答案 0 :(得分:0)

安装此chrome扩展程序。它会自动为您提供钛应用程序的路径

https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc?hl=en

由于

答案 1 :(得分:0)

更容易看到你如何解析json

试试这个: GetDoctorFavoriteTestResult [0] .TestDetails