Json 从图像裁剪器属性获取图像id

Json 从图像裁剪器属性获取图像id,json,json.net,umbraco7,Json,Json.net,Umbraco7,我正在尝试获取Umbraco的image Cropper属性的图像ID,以便将其与TypedMedia(ID).GetResponsiveCropUrl()方法一起使用 我正在努力只提取ID。我当前的实现item.GetProperty(“mainImage”).Value.ToString()返回由其他图像裁剪器数据组成的JSON对象,例如焦点: { "focalPoint": { "left": 0.71111111111111114, "top": 0.57 }, "src": "/med

我正在尝试获取Umbraco的image Cropper属性的图像ID,以便将其与
TypedMedia(ID).GetResponsiveCropUrl()
方法一起使用

我正在努力只提取ID。我当前的实现
item.GetProperty(“mainImage”).Value.ToString()
返回由其他图像裁剪器数据组成的JSON对象,例如焦点:

{ "focalPoint": { "left": 0.71111111111111114, "top": 0.57 }, "src": "/media/1004/9910_03_7326-river-flood_web.jpg", "crops": [ { "alias": "Carousel", "width": 700, "height": 400 } ] }1156
检索图像ID的最佳方法是什么

这是我的实现:

 foreach (Node item in Node.GetCurrent().GetDescendantNodes())
 {
    if (item.GetProperty<bool>("showInNewsCarousel") == true)
    {
        Response.Write(item.GetProperty("mainImage").Value.ToString());
    //    var slideImage = Umbraco.Media(item.GetProperty("mainImage").Value);
        <img class="img-responsive" src="@Umbraco.TypedMedia(1155).GetResponsiveCropUrl("Carousel")" />
    }
}
foreach(Node.GetCurrent().getgenderantnodes()中的节点项)
{
if(item.GetProperty(“showInNewsCarousel”)==true)
{
Write(item.GetProperty(“mainImage”).Value.ToString();
//var slideImage=Umbraco.Media(item.GetProperty(“mainImage”).Value);
}
}

您在评论中提到的
1156
值是图像ID实际上不是JSON的一部分,但似乎是后来添加的。(如果您尝试在验证字符串,您将看到我的意思。)由于ID不是JSON的一部分,您将无法使用JSON解析器获取值。我认为你最好的办法就是找到最后一个最后一个大括号,然后把所有的东西都拿走

string id = json.Substring(json.LastIndexOf('}') + 1).Trim();

JSON末尾的
1156
是什么?这就是你所说的图像ID吗?谢谢你的回答,我本来想获取子字符串,但放弃了这个想法,因为在Umbraco中必须有更好的方法来获取ID属性。