Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "id": "test@gmail.com",
- "active": 1,
- "is_logged": true,
- "token": "hsja3t56yJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3RAZHZlby5jb20iLCJwYXNzd29yZCI6InRlc3QyMDE4KyIsImV4cGlyZU9uIjoiMjAxOS0wNi0yMVQwNTozNzowOC4xODhaIn0.3wgGeL_HvcoEJJeEF7tj8jeXk2uIKpOoi9ewmK5yhteh",
- "status": "OK",
- "usertype": "TestUser",
- "msg": "Login Successfull."
- }
- string[] sep = response.Split(',');
- foreach (string any in sep)
- Console.WriteLine(any);
- //string[] colon = sep[0].Split(':');
- string[][] colon = sep.Select(x => x.Split(':')).ToArray();
- //int count = colon.Count();
- for (int i = 0; i <= colon.Length; i++)
- {
- Console.WriteLine(colon[i][0]);
- Console.WriteLine(colon[i][1]);
- }
- public class UserData
- {
- public string id { get; set; }
- public int active { get; set; }
- public bool is_logged { get; set; }
- public string token { get; set; }
- public string status { get; set; }
- public string usertype { get; set; }
- public string msg { get; set; }
- }
- string response = "{"id":"test @gmail.com","active":1,"is_logged":true,"token":"hsja3t56yJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3RAZHZlby5jb20iLCJwYXNzd29yZCI6InRlc3QyMDE4KyIsImV4cGlyZU9uIjoiMjAxOS0wNi0yMVQwNTozNzowOC4xODhaIn0.3wgGeL_HvcoEJJeEF7tj8jeXk2uIKpOoi9ewmK5yhteh","status":"OK","usertype":"TestUser","msg":"Login Successfull."}";
- var responseData = JsonConvert.DeserializeObject<UserData>(response);
- //here the print in JSON Data
- Console.WriteLine("id : " + responseData.id);
- Console.WriteLine("active : " + responseData.active);
- Console.WriteLine("is_logged : " + responseData.is_logged);
- Console.WriteLine("token : " + responseData.token);
- Console.WriteLine("status : " + responseData.status);
- Console.WriteLine("usertype : " + responseData.usertype);
- Console.WriteLine("msg : " + responseData.msg);
- JObject jo = JObject.Parse(searchCondition);
- foreach (JToken child in jo.Children()) {
- var prop = child as JProperty;
- if (prop.Value != null && !string.IsNullOrEmpty(prop.Value.ToString())) {
- string name=prop.Name;
- string value = prop.Value;
- //You can now do whatever with the values like put in a list of object
- }
- }
- using System;
- using Newtonsoft.Json.Linq;
- public class Program
- {
- public static void Main()
- {
- string jsonString = "{"firstname":"Alex Wu","lastname":"type"}";
- JObject jObject = JObject.Parse(jsonString);
- string firstname = (string)jObject.SelectToken("firstname");
- string lastname = (string)
- Console.WriteLine("{0}", firstname);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement