我有如下所示的字符串
"{\"id\":\"3b6f\",\"campaign_title\":\"\",\"type\":\"regular\",\"list_id\":\"aaeb6\",\"list_name\":\"FT-2\",\"subject_line\":\"Funtional Testing 2 Campaign\",\"emails_sent\":4,\"abuse_reports\":0,\"unsubscribed\":1,\"send_time\":\"2017-01-03T07:50:27+00:00\",\"bounces\":{\"hard_bounces\":0,\"soft_bounces\":0,\"syntax_errors\":0},\"forwards\":{\"forwards_count\":0,\"forwards_opens\":0},\"opens\":{\"opens_total\":2,\"unique_opens\":2,\"open_rate\":0.5,\"last_open\":\"2017-01-03T08:05:28+00:00\"},\"clicks\":{\"clicks_total\":0,\"unique_clicks\":0,\"unique_subscriber_clicks\":0,\"click_rate\":0,\"last_click\":\"\"},\"facebook_likes\":{\"recipient_likes\":0,,\"targetSchema\":\"https://us14.api.mailchimp.com/schema/3.0/Definitions/Reports/Unsubscribed/CollectionResponse.json\"}]}"
我需要从这个字符串中找到值。例如{\" id \":\" 3b6f \"。我需要3b6f来自这个字符串。如何从此字符串中获取所需内容?
答案 0 :(得分:1)
您可以使用JSon.net轻松完成:
JObject.Parse(yourJson)["id"]
但你的json无效,我收到错误信息:
无效的属性标识符:。路径 'facebook_likes.recipient_likes',第1行,第582位。
你有一个额外的逗号,你有一个关闭数组括号而不打开一个。有效的json可以是:
{\ “ID \”:\ “3b6f \”,\ “campaign_title \”:\ “\” \ “类型\”:\ “正规\”,\ “LIST_ID \”:\ “aaeb6 \” ,\ “LIST_NAME \”:\ “FT-2 \”,\ “SUBJECT_LINE \”:\“泛函 测试2 运动\ “\ ”emails_sent \“:4,\ ”abuse_reports \“:0,\ ”退订\“:1,\ ”send_time \“:\” 2017-01-03T07:50:27 + 00:00 \ ” \ “反弹\”:{\ “hard_bounces \”:0,\ “soft_bounces \”:0,\ “syntax_errors \”:0},\ “向前\”:{\ “forwards_count \”:0,\ “forwards_opens \”:0},\ “打开\”:{\ “opens_total \”:2,\ “unique_opens \”:2,\ “open_rate \”:0.5,\ “last_open \”:\“2017-01 -03T08:05:28 + 00:00 \ “},\” 点击\ “:{\” clicks_total \ “:0,\” unique_clicks \ “:0,\” unique_subscriber_clicks \ “:0,\” click_rate \” :0,\ “last_click \”:\ “\”},\ “facebook_likes \”:{\ “recipient_likes \”:0,\ “targetSchema \”:\ “https://us14.api.mailchimp.com/schema/3.0/Definitions/Reports/Unsubscribed/CollectionResponse.json \”}}