12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using LitJson;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class AllTool : MonoBehaviour
- {
- /// <summary>
- /// 获取当前时间戳
- /// </summary>
- /// <returns></returns>
- public static long GetTimeStamp()
- {
- return (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
- }
- /// <summary>
- /// Json 解析
- /// </summary>
- /// <param name="message"></param>
- /// <returns></returns>
- public static Root ToJsonData(String message)
- {
- try
- {
- JsonData json = JsonMapper.ToObject(message);
- JsonData data = json["projectinfo"]["navLines"];
- message = data.ToJson();
- //message = message.Substring(1, message.Length - 1);
- 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;
- }
- }
- }
|