Guest User

Untitled

a guest
Jan 22nd, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. Webclient.Downloadstring();
  2.  
  3. var data = "{"err":[],"msg":[],"state":null," +
  4. "rec":{"Vin":"1ABC2DEF3GH45678"," +
  5. ""REG":"ST-ABC123","int":"12345678"," +
  6. ""Make":"GMC","Model":"YUKON"," +
  7. ""Type":"SUV","Color":"black metallic",";
  8.  
  9. public class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13.  
  14.  
  15. var data = "{"err":[],"msg":[],"state":null," +
  16. "rec":{"Vin":"1ABC2DEF3GH45678"," +
  17. ""REG":"ST-ABC123","int":"12345678"," +
  18. ""Make":"GMC","Model":"YUKON"," +
  19. ""Type":"SUV","Color":"black metallic",";
  20.  
  21. data = doc.Replace('{', ' ');
  22. data = doc.Replace('"', ' ');
  23. data = doc.Replace('}', ' ');
  24. var sub = data.Split(':', ',');
  25.  
  26. for(int i = 0; i < sub.Length; i++)
  27. {
  28. sub[i] = sub[i].Trim();
  29.  
  30. /*Console.WriteLine("{0} : {1}", i, sub[i]);
  31. Outputs :
  32. 0 : err
  33. 1 : []
  34. 2 : msg
  35. 3 : []
  36. 4 : state
  37. 5 : null
  38. 6 : rec
  39. 7 : Vin
  40. 8 : 1ABC2DEF3GH45678
  41. 9 : REG
  42. 10 : ST-ABC123
  43. 11 : int
  44. 12 : 12345678
  45. 13 : Make
  46. 14 : GMC
  47. 15 : Model
  48. 16 : YUKON
  49. 17 : Type
  50. 18 : SUV
  51. 19 : Color
  52. 20 : black metallic
  53. 21 :
  54. */
  55. }
  56.  
  57. Vehicle vehicle = new Vehicle(sub[8], sub[10], sub[12], sub[14], sub[16], sub[18], sub[20]);
  58. }
  59. }
  60.  
  61. public class Vehicle
  62. {
  63. public string Vin { get; set; }
  64. public string Registration { get; set; }
  65. public string ID { get; set; }
  66. public string Make { get; set; }
  67. public string Model { get; set; }
  68. public string VehicleType { get; set; }
  69. public string Color { get; set; }
  70. public string Nav { get; set; }
  71. public string Transmission { get; set; }
  72.  
  73. public Vehicle(string _Vin, string _Reg, string _ID, string _Make, string _Model, string _Type, string _Color)
  74. {
  75. this.Vin = _Vin;
  76. this.Registration = _Reg;
  77. this.ID = _ID;
  78. this.Make = _Make;
  79. this.Model = _Model;
  80. this.VehicleType = _Type;
  81. this.Color = _Color;
  82. }
  83. }
Add Comment
Please, Sign In to add comment