123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using LitJson;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using TMPro;
- using UnityEngine;
- public class JsonControl : MonoBehaviour
- {
- private static JsonControl instance;
- private JsonControl()
- {
- }
- public static JsonControl Instance()
- {
- if (instance == null)
- instance = new JsonControl();
- return instance;
- }
-
-
-
-
-
- public Root ToJsonData(String message)
- {
-
- try
- {
- JsonData json = JsonMapper.ToObject(message);
- JsonData data = json["projectinfo"]["navLines"];
- message = data.ToJson();
-
- message = "{\"navLines\":" + message + "}";
- Debug.Log(message);
- Root root = JsonMapper.ToObject<Root>(message);
- Debug.Log(root.navLines.Count);
- return root;
- }
- catch (Exception)
- {
- Debug.LogError("Json 传入格式不正确 无法解析" );
- return null;
- }
-
- }
- }
- public class MPItem
- {
-
-
-
- public double X { get; set; }
-
-
-
- public double Y { get; set; }
-
-
-
- public double Z { get; set; }
- }
- public class PointsItem
- {
-
-
-
- public double X { get; set; }
-
-
-
- public double Y { get; set; }
-
-
-
- public double Z { get; set; }
-
-
-
- public int T { get; set; }
-
-
-
- public int TL { get; set; }
-
-
-
- public int TH { get; set; }
-
-
-
- public string MN { get; set; }
-
-
-
- public string ML { get; set; }
-
-
-
- public int D { get; set; }
-
-
-
-
-
-
- public List<MPItem> MP { get; set; }
- }
- public class NavLinesItem
- {
-
-
-
- public string name { get; set; }
-
-
-
- public List<PointsItem> points { get; set; }
- }
- public class Root
- {
-
-
-
-
-
-
-
- public List<NavLinesItem> navLines { get; set; }
- }
- public class Data
- {
- public int status { get; set; }
- public string registe { get; set; }
- public string tagid { get; set; }
- public List<Root> projectinfo { get; set; }
- }
|