weixin_33688840 2018-06-11 04:30 采纳率: 0%
浏览 27

json错误,意外的'<'

I'm using javascript to receive data from an arduino, to save the data on the database i'm using dapper and to test it i'm using postman.

Here's my javascript code for receiving the Json data. I'm compairing the names on my javascript code (which are use to receive the data) with the ones i'm using on my c# code that are mapped with my database, if the names match then save the data i just received in my database and post it on my website

 var Latitude = ("#Latitude").val();
    var Longitude = ("#Longitude").val();
    var Country = ("#Country").val();
    var ObtainedDate = ("#ObtainedDate").val();

$.ajax({
    type: 'POST',
    url: 'http://localhost:59319/Home/Map',
    data: { Latitude: Latitude, Longitude: Longitude, Country: Country, ObtainedDate: ObtainedDate },
    dataType: "json",
    success: function (lctn) {
        $.each(lctn, function (i, lctns) {
            $lctn.append(lctns.Latitude + lctns.Longitude + lctns.Country + lctns.ObtainedDate)
        });

    }
});

Here's the code i used to connect to my data base

SqlConnection conn = new SqlConnection();


    public GeoDapperConnection()
    {
        conn.ConnectionString = "Server=tcp:espejo.database.windows.net,1433;Initial Catalog=DbEspejo;Persist Security Info=False;User ID=IntecEspejo;Password=P@ssw0rd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

        var data = conn.Query<Geography>("SELECT * FROM GEOGRAPHY").ToList();
    }

This is to show the data from my data base

public List<Geography> Locations()
    {
        conn.Open();

        var data = conn.Query<Geography>("GET_LOCATION", null, commandType: System.Data.CommandType.StoredProcedure).ToList();

        conn.Close();

        return data;
    }

And this code is to receive the data from the javascript part and send it to my database

public void ReceiveData(Geography Geo)
        {
            conn.Open();
            var queryParameters = new DynamicParameters();
            queryParameters.Add("@Lat", Geo.Latitude);
            queryParameters.Add("@Long", Geo.Longitude);
            queryParameters.Add("@Country", Geo.Country);
            queryParameters.Add("@DateCreated", Geo.ObtainedDate);


            var data = conn.Query("INSERT_LOCATION", queryParameters, commandType: System.Data.CommandType.StoredProcedure);


            conn.Close();

        }

Here's the json data i'm posting to my website Postman

Here's the picture of my website, it doesn't show me on my list my new data

Map

And this is my Geography class

public class Geography
    {
        [Key]
        public int RouteID { get; set; }

        public double Latitude { get; set; }
        public double Longitude { get; set; }

        public string ISO { get; set; }
        public string Country { get; set; }
        public string ISO3 { get; set; }

        public DateTime ObtainedDate { get; set; }
    }
  • 写回答

0条回答 默认 最新

      报告相同问题?

      悬赏问题

      • ¥60 悬赏求解,通过实时现场摄像头的视频图像识别其他对家打出的麻将牌,识别麻将牌,识别牌墙位置,通过识别对家打出了什么牌
      • ¥15 关于#GPU jetson#的pcie驱动开发问题,如何解决?
      • ¥15 stm32f103zet6 串口5无法收发数据
      • ¥15 关于C语言使用线程队列实现多线程并发
      • ¥15 这个运行,错误在哪里呀,大家看看吧,教导我
      • ¥15 advanceinstaller对话框设置
      • ¥100 正常上网,内部网页无法打开
      • ¥15 组件库引入并使用在若依框架未展示
      • ¥149 关于#使用python 的Flash Echarts+ajax+mysql动态数据实现饼图#的问题,请各位专家解答!
      • ¥15 RichTextBox中追加文本时报错