Home > Net >  Method for parsing a string
Method for parsing a string

Time:09-18

{"code":"200","msg":"[name|strategy|moh_sound|time_base_score|tier_rules_apply|tier_rule_wait_second|tier_rule_wait_multiply_level|tier_rule_no_agent_no_wait|discard_abandoned_after|abandoned_resume_allowed|max_wait_time|max_wait_time_with_no_agent|max_wait_time_with_no_agent_time_reached|record_template|calls_answered|calls_abandoned|ring_progressively_delay|skip_agents_with_external_calls|agent_no_answer_status, 806900@zy|ring-all|local_stream://moh|system|false|300|true|false|60|false|60|0|5||0|0|0|true|On Break, zy@default|ring-all|local_stream://moh|system|false|300|true|false|60|false|0|0|5||0|0|0|true|On Break, support@default|ring-all|local_stream://moh|system|false|300|true|false|60|false|0|0|5||0|0|0|true|On Break, yx@default|ring-all|local_stream://moh|system|false|300|true|false|60|false|60|0|5||0|0|0|true|On Break, zxz@dscy|round-robin|C:\\Program Files\\FreeSWITCH\\sounds\\ivr\\gyk\\dlzsbjy.wav|system|false|300|true|false|300|true|290|290|5||403|152|0|true|On Break, 806901@zy|ring-all|local_stream://moh|system|false|300|true|false|60|false|60|0|5||0|0|0|true|On Break, zydl@default|ring-all|C:\\Program Files\\FreeSWITCH\\sounds\\wav\\noworktime.wav|system|false|300|true|false|60|false|0|0|5||0|0|0|true|On Break, 999@zy|ring-all|C:\\Program Files\\FreeSWITCH\\sounds\\zx.wav|system|false|300|true|false|60|false|60|0|5||0|0|0|true|On Break, 1019@zy|ring-all|C:\\Program Files\\FreeSWITCH\\sounds\\ivr\\gyk\\dlzsbjy.wav|system|false|300|true|false|60|false|60|0|5||0|34|0|true|On Break, 1010@zy|ring-all|C:\\Program Files\\FreeSWITCH\\sounds\\ivr\\gyk\\dlzsbjy.wav|system|false|300|true|false|60|false|60|0|5||7|72|0|true|On Break, +OK]","data":null}


How to parse out the inside of the MSG content? Please advice, thank you

CodePudding user response:

Deserialized into a class object, after the MSG string grouping,

CodePudding user response:

reference 1st floor exception92 response:
deserialized into a class object, after the MSG string grouping,


Why to take a MSG only, to build an object? Other attributes the original poster don't again,

Two other code to fix things,

Using Newtonsoft. Json. Linq;

JToken JToken=JToken. Parse (string);
String MSG=jToken [r]. "MSG" ToString ();

CodePudding user response:

reference 3 floor however response:
Quote: refer to 1st floor exception92 response:

Deserialized into a class object, then the MSG string grouping,


Why to take a MSG only, to build an object? Other attributes the original poster don't again,

Two other code to fix things,

Using Newtonsoft. Json. Linq;

JToken JToken=JToken. Parse (string);
String MSG=jToken [r]. "MSG" ToString ();

The study,

CodePudding user response:

Exception92
reference 4 floor response:
Quote: refer to 3rd floor big though response:

Quote: refer to 1st floor exception92 response:

Deserialized into a class object, then the MSG string grouping,


Why to take a MSG only, to build an object? Other attributes the original poster don't again,

Two other code to fix things,

Using Newtonsoft. Json. Linq;

JToken JToken=JToken. Parse (string);
String MSG=jToken [r]. "MSG" ToString ();

Learning,


reference 3 floor however response:
Quote: refer to 1st floor exception92 response:

Deserialized into a class object, then the MSG string grouping,


Why to take a MSG only, to build an object? Other attributes the original poster don't again,

Two other code to fix things,

Using Newtonsoft. Json. Linq;

JToken JToken=JToken. Parse (string);
String MSG=jToken [r]. "MSG" ToString ();

To study the

CodePudding user response:

You can also use JObject + dynamic, flexible individuals prefer,
 string val="{" code \ ": " 200 \ "and " MSG \ ": " [name | strategy | moh_sound + OK] \ "and " data \ ": null}"; 
//1
The dynamic obj=JObject. Parse (val);
Console. WriteLine (obj. MSG);

//2
Var obj2=JToken. Parse (val);
String MSG=obj2 (" MSG "). The ToString ();
Console. WriteLine (MSG);

CodePudding user response:

This is the json format, use json.net to unpack the first, and then the rest of the things the CSV format,
  •  Tags:  
  • C#
  • Related