TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Durga Prasad Karrothu
NA
15
11.6k
how can i get the json intent data in to c#?
Feb 28 2018 11:13 PM
Below is my class for the json output:
class
PwdResetRequest
{
public
class
TopScoringIntent
{
public
string
intent {
get
;
set
; }
public
double
score {
get
;
set
; }
}
public
class
Intent
{
public
string
intent {
get
;
set
; }
public
double
score {
get
;
set
; }
}
public
class
Resolution
{
public
string
value {
get
;
set
; }
}
public
class
Entity
{
public
string
entity {
get
;
set
; }
public
string
type {
get
;
set
; }
public
int
startIndex {
get
;
set
; }
public
int
endIndex {
get
;
set
; }
public
Resolution resolution {
get
;
set
; }
}
public
class
RootObject
{
public
string
query {
get
;
set
; }
public
TopScoringIntent topScoringIntent {
get
;
set
; }
public
List<Intent> intents {
get
;
set
; }
public
List<Entity> entities {
get
;
set
; }
}
}
Luis Return result:
{
"query"
:
"create a new password for
[email protected]
"
,
"topScoringIntent"
: {
"intent"
:
"ResetLANIDpassword"
,
"score"
: 0.9956063 },
"intents"
: [ {
"intent"
:
"ResetLANIDpassword"
,
"score"
: 0.9956063 }, {
"intent"
:
"None"
,
"score"
: 0.179328963 } ],
"entities"
: [ {
"entity"
:
"
[email protected]
"
,
"type"
:
"builtin.email"
,
"startIndex"
: 26,
"endIndex"
: 47 } ] }
I have developed the below code for getting the data from the json.
var uri =
"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/"
+ luisAppId +
"?"
+ queryString;
var response = await client.GetAsync(uri);
var strResponseContent = await response.Content.ReadAsStringAsync();
var json = await response.Content.ReadAsStringAsync();
var token = JObject.Parse(json).SelectToken(
"entities"
);
foreach
(var item
in
token)
{
var request = item.ToObject<Entity>();
}
// Display the JSON result from LUIS
Console.WriteLine(strResponseContent.ToString());
}
And I only want the data from the "TopScoringIntent". How can I get that using C#? Below is the code that I tried but nothing came out: Message=Error reading JObject from JsonReader. Path '', line 0, position 0. Source=Newtonsoft.Json
Reply
Answers (
7
)
How to search value from txt file through C#
How to insert table into word document in specific position.