【发布时间】:2014-12-24 12:05:04
【问题描述】:
我的 WEC 网络服务返回一个 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它显示为空。
即使在浏览器中,Web 服务也能完美运行。
再次,我可以在 Titanium 控制台窗口中看到数组数据。
有什么办法吗?
【问题讨论】:
-
你在 PC 或 mac 上安装了 chrome 吗?
-
PC,暂时为安卓工作。
-
铬?我说的是钛,是的,我在 chrome 和 firefox 中测试了该服务,但数据相同。
-
我有 chrome,现在该怎么办?
-
你能把GetDoctorFavoriteTestResult.TestDetails周围的代码展示一下吗
标签: javascript json titanium