希望有人可以提供帮助 - 我没有随处可见。 我创建了一个由一些Umbraco节点组成的序列化JSON字符串,我试图使用JQuery获取某些属性的值。
附加图像是阵列的结构,使用Chrome开发工具进行检查:
正如您所看到的,对象中有3个数组,每个数组中有12个具有3个属性的对象。 数组的结构是这样的,因为我使用的是getJSON()方法。
尽我所能,我似乎无法访问此属性。
我已经从JQuery中删除了所有内容,留下了裸露的骨头:
<script type="text/javascript">
$(document).ready(function () {
$.getJSON('http://myURLCaseStudyImagesJSON', function (data) {
});
});
</script>
如果有人能就如何做到这一点提出建议,我将非常感激。 我不想最终加载嵌套for循环,但即使尝试它也不会给出结果。 实际的原始JSON是这样的:
[[{"Alias":"googleAC","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"metaKeywords","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"metaDescription","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageTitle","Value":"Royal","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageHeading","Value":"Royal Heading","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageSubHeading","Value":"Royal Sub Heading","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageContent","Value":"\u003cp\u003eRoyal\u003c/p\u003e","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caption","Value":"Dave didn\u0027t wait to book. We didn\u0027t wait to blink.","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyMainImage","Value":"1357","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyImages","Value":"1357","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"displayHomePageCarousel","Value":"1","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"imageUrl","Value":"/media/8777/swimmer.jpg","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyUrl","Value":"/our-work/advertising-and-promotions/royal/","Version":"00000000-0000-0000-0000-000000000000"}],[{"Alias":"googleAC","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"metaKeywords","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"metaDescription","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageTitle","Value":"Walter Title","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageHeading","Value":"Walter Heading","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageSubHeading","Value":"Walter Sub Heading","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageContent","Value":"\u003cp\u003eWalter Content\u003c/p\u003e","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caption","Value":"Mickey waved his magic wand and magic happened","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyMainImage","Value":"1355","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyImages","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"displayHomePageCarousel","Value":"1","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"imageUrl","Value":"/media/8767/mickey.jpg","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyUrl","Value":"/our-work/brandingcorporate-identity/walter/","Version":"00000000-0000-0000-0000-000000000000"}],[{"Alias":"googleAC","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"metaKeywords","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"metaDescription","Value":"","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageTitle","Value":"Sea Life","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageHeading","Value":"Sea Life Heading","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageSubHeading","Value":"Sea Life Sub Heading","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"pageContent","Value":"\u003cp\u003eSea Life Content\u003c/p\u003e","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caption","Value":"Sea life it\u0027s an education","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyMainImage","Value":"1356","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyImages","Value":"1356","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"displayHomePageCarousel","Value":"1","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"imageUrl","Value":"/media/8772/shark.jpg","Version":"00000000-0000-0000-0000-000000000000"},{"Alias":"caseStudyUrl","Value":"/our-work/print-designproduction/sea-life/","Version":"00000000-0000-0000-0000-000000000000"}]]
希望有人可以提供帮助。
由于
答案 0 :(得分:1)
您使用什么来将Umbraco对象序列化为JSON?在JSON.net中,您可以创建可以重新格式化数据的序列化程序,以使13个对象中的每个对象成为实际的键/值对,这样它们就可以拥有您期望的属性。
以下是JsonSerializer上的一些链接:
http://blog.maskalik.com/asp-net/json-net-implement-custom-serialization
How to implement custom JsonConverter in JSON.NET to deserialize a List of base class objects?
答案 1 :(得分:0)
我设法通过嵌套$ .each循环来做到这一点,我并不是真的想要 - 但是我读了一个论坛帖子,说你不能真正拥有多维jQuery数组,这将是最好的方法这样做。