0

希望有人可以提供帮助-我对此无能为力。我创建了一个由一些 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"}]]

希望有人可以提供帮助。

谢谢

4

2 回答 2

1

你用什么将 Umbraco 对象序列化为 JSON?在 JSON.net 中,您可以创建可以重新格式化数据的序列化程序,以使 13 个对象中的每一个都成为实际的键/值对,以便它们具有您期望的属性。

以下是 JsonSerializer 上的一些链接:

http://blog.maskalik.com/asp-net/json-net-implement-custom-serialization

如何在 JSON.NET 中实现自定义 JsonConverter 以反序列化基类对象列表?

于 2013-01-17T23:01:35.013 回答
0

我设法通过嵌套 $.each 循环来做到这一点,这是我并不真正想要的——但我读了一篇论坛帖子,上面说你不能真正拥有多维 jQuery 数组,这将是最好的方法.

于 2013-01-18T11:00:36.053 回答