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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
    • ¥15 画两个图 python或R
    • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
    • ¥15 八路抢答器设计出现故障
    • ¥15 opencv 无法读取视频
    • ¥15 按键修改电子时钟,C51单片机
    • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))