Json反序列化.net

 1 // Generated by Xamasoft JSON Class Generator
 2 // http://www.xamasoft.com/json-class-generator
 3 
 4 using System;
 5 using System.Collections.Generic;
 6 using Newtonsoft.Json;
 7 using Newtonsoft.Json.Linq;
 8 
 9 namespace Geographic
10 {
11 
12     public partial class LineTarget
13     {
14         public class SpatialReference2
15         {
16         }
17     }
18 
19     public partial class LineTarget
20     {
21 
22         [JsonProperty("paths")]
23         public double[][][] Paths;
24 
25         [JsonProperty("spatialReference")]
26         public SpatialReference2 SpatialReference;
27     }
28 
29 }
View Code
 1 // Generated by Xamasoft JSON Class Generator
 2 // http://www.xamasoft.com/json-class-generator
 3 
 4 using System;
 5 using System.Collections.Generic;
 6 using Newtonsoft.Json;
 7 using Newtonsoft.Json.Linq;
 8 
 9 namespace Geographic
10 {
11 
12     public partial class PointTarget
13     {
14         public class SpatialReference2
15         {
16         }
17     }
18 
19     public partial class PointTarget
20     {
21 
22         [JsonProperty("x")]
23         public double X;
24 
25         [JsonProperty("y")]
26         public double Y;
27 
28         [JsonProperty("spatialReference")]
29         public SpatialReference2 SpatialReference;
30     }
31 
32 }
View Code
 1    public void getdbiao()
 2         {
 3 
 4             string db = "{\"x\":40058.62363275346,\"y\":33759.8081053848,\"spatialReference\":{}}";
 5             
 6             string xb = "{\"paths\":[[[61445.29960940048,44306.6620116765],[64960.917578164386,38447.29873040334]]],\"spatialReference\":{}}";
 7             LineTarget linetarget = JsonConvert.DeserializeObject<LineTarget>(xb);
 8           
 9             string xianbiao = "[" + linetarget.Paths[0][0][0] + "," + linetarget.Paths[0][0][1] + "]," + "[" + linetarget.Paths[0][1][0] + "," + linetarget.Paths[0][1][1] + "]";
10             PointTarget pointtarget = JsonConvert.DeserializeObject<PointTarget>(db);
11             double dibiao_x = pointtarget.X;
12             double dibiao_y = pointtarget.Y;
13         }
View Code

 

posted @ 2015-04-29 13:51  Jbp  阅读(163)  评论(0)    收藏  举报