Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This is my JObject.Parse string.
{"topic":{"account_id":190884,"created_at":"2015-01-31T16:35:59+05:00","delta":true,"forum_id":5000225377,"hits":0,"id":5000025527,"import_id":null,"last_post_id":5000040596,"locked":false,"merged_topic_id":null,"posts_count":0,"published":true,"replied_at":"2015-01-31T16:35:59+05:00","replied_by":5005399997,"stamp_type":null,"sticky":0,"title":"I want use API of Freshdesk.","updated_at":"2015-01-31T16:35:59+05:00","user_id":5005399997,"user_votes":0,"posts":[{"account_id":190884,"answer":false,"body":" I want to use API of Freshdesk to get forums of Freshdesk. I want to access users and posts from different Forums and show that data in my Application. I want to develop C# console Application.\u00a0 Anyone please help me. \r\n","body_html":"\u003Cp\u003EI want to use API of Freshdesk to get forums of Freshdesk. I want to access users and posts from different Forums and show that data in my Application. I want to develop C# console Application.\u00a0\u003C/p\u003E\u003Cp\u003EAnyone please help me.\u003C/p\u003E\r\n","created_at":"2015-01-31T16:35:59+05:00","forum_id":5000225377,"id":5000040596,"import_id":null,"published":true,"spam":null,"topic_id":5000025527,"trash":false,"updated_at":"2015-01-31T16:35:59+05:00","user_id":5005399997}]}}
I want to get values of (posts) from this string in C#. Anyone can help me how i can get values of posts from this string.
Use Newtonsoft's Json.net
https://www.nuget.org/packages/Newtonsoft.Json/
It is an easy to use library:
Example:
string json = #"{
'Name': 'Bad Boys',
'ReleaseDate': '1995-4-7T00:00:00',
'Genres': [
'Action',
'Comedy'
]
}";
Movie m = JsonConvert.DeserializeObject<Movie>(json);
string name = m.Name;
var s=<json_string>;
var firstPost = JObject.Parse(s)["topic"]["posts"][0];
string postBody = (string)firstPost["body"];
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
In my project; I have so many json file from web. And inside json file have campaign datas. But that data numbers is always changing. For example in first json it have 5 data and other json have 15. So I need create labels for that datas. For example if in the json file have 5 campaign data , i need create 5. İf it have 10 then i need create 10. Like this. So how can i make it ? I input json files and its works correctly i just need learn how can i create , position N label in xamarin ? Thanks for your help! <3
just create them and add them to some layout container, like this
var stack = new StackLayout();
foreach(var l in LabelData())
{
stack.Children.Add(new Label { Text = l.SomeProperty });
}
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Intro: Im saving in a DB a template of certain inputs that have to be taken as inputs, so it's not the same every time it operates, sometimes could be 2 others could be 12.
But still want to use a single post/get request (with variable numbers of arguments, that somehow i can recognize), is there a way of doing this in C# backend with and without using a json?
Thanks
Given you're developing a Web API that sends/receives JSON data, it would make sense for the variable fields to be an additional JSON object within the request model of the API. Something along the lines of:
public class YourRequestApiModel
{
public JsonDocument CustomData { get; set; }
// ...
}
Then when sending your request, you could easily serialize an IDictionary<string, object> into a JSON structure to send to your API, e.g.:
{
"customData": {
"customerName": "Mario",
"purchaseYear": 2020,
"isFirstPurchase": true,
"comments": null
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
My question is about the following html: https://pastebin.com/qT97gBh5
I download the HTML Site by using
var url = "https://www.twitch.tv/monstercat";
var web = new HtmlWeb();
var doc = web.Load(url);
Now the only thing that interests me is the JSON Data off the following section.
<script type="application/ld+json">[{"#context":"http://schema.org","#type":"VideoObject","thumbnailUrl":["https://static-cdn.jtvnw.net/previews-ttv/live_user_monstercat-{width}x{height}.jpg"],"embedUrl":"https://player.twitch.tv/?channel=monstercat&player=facebook&autoplay=true","name":"Monstercat - Twitch","description":"Non Stop Music - Monstercat Radio 🎶","videoQuality":"1080p","publication":{"#type":"BroadcastEvent","isLiveBroadcast":true,"startDate":"03/29/2020 19:04:06"},"author":{"#type":"Person","name":"Monstercat","url":"https://www.twitch.tv/monstercat"},"uploadDate":"03/29/2020 19:04:06"}]</script>
How would i use HtmlAgilityPack to use the xpath
/html/head/script[2] to receive the JSON Data?
you can search about agility pack in c# and after that use agility to get this X path
/html/head/script[2]
now you have a json string. convert json to property with newtonsoft(add this package with Nuget).congratulation so you can read description in your class.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have the following code :
string messageString1 = JsonConvert.SerializeObject(thisComputer);
var data = new { deviceid = "info1", devicetype = "info2", data = messageString1};
My goal is to add messageString1 into data .
thisComputer is a class and i know this part of the code works , because i got it working before , i'm just not being capable to get messageString1 into data.
I am not being able to insert data into data.I have tried several different ways but i still haven't figure it out.
EDIT:
the problem is that i am trying to send the JSON to azure IoThub and in fact the contents are getting trough and into IoT Hub but all the double quotes characters are now '\"' and that constitutes the problem .
EXAMPLE: If the data inside is :
{"data":"dataInfo"}
in Iot Hub i see :
{\"data\":\datainfo\"}
Thanks in advance.
Currently, you're JSON-encoding an object as a string, and then when you're sending the anonymous type instance to Cloud IoT, that's applying JSON encoding again.
It looks like you don't want the value of data to be a string - you want it to be the data from thisComputer. So just avoid that first level of encoding:
var data = new { deviceid = "info1", devicetype = "info2", data = thisComputer };
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have an array of json objects with the following content:
[
{
"id":"4d631c00-81b6-11e5-a433-eb40dfe04266",
"name":"a",
"parent":"123",
"main_organisation":"#",
"active":1,
"contact_person":"aa",
"resp_consultant":"a",
"address_1":"a",
"goals":null,
"address_2":"a",
"org_nr":"a",
"zip":"a",
"city":"aa",
"country":"a",
"www":"a",
"email":"aa",
"phone":"a",
"misc":"aa",
"subscription":0,
"address_visit":"a"
}
{
...etc
}
]
I also want to put the id and name values in a list, I would be so happy if anyone could help me!
A resarch in google have been helpful...
Please have a look at newtosoft : http://www.newtonsoft.com/json
You have all the samples to do what you want with your json array.