繁体   English   中英

Java对象数组到Javascript对象数组作为参数

[英]Java Object array to Javascript Object Array as parameter

如何将对象的Java数组发送到javascript函数?

这是我的对象

class SitioMapa{
    String title;
    double lat;
    double lng;
    String description;

    public SitioMapa(String title,double lat,double lng,String description) {
        this.title=title;
        this.lat=lat;
        this.lng=lng;
        this.description=description;       
    }
}

传递给JSon看起来像

"SitioMapa":[{"title":"Alibaug","lat":"18.641400","lng":"72.872200","description": "Alibaug is a coastal town and a municipal council in Raigad District in the Konkan region of Maharashtra, India."},{...},{...}]

我将一个充满上述对象的SitioMapa []数组发送到javascript中的函数,但是我需要在一些东西中隐藏该数组

var markers = [
        {
            "title": 'Alibaug',
            "lat": '18.641400',
            "lng": '72.872200',
            "description": 'Alibaug is a coastal town and a municipal council in Raigad District in the Konkan region of Maharashtra, India.'
        }
    ,
        {
            "title": 'Mumbai',
            "lat": '18.964700',
            "lng": '72.825800',
            "description": 'Mumbai formerly Bombay, is the capital city of the Indian state of Maharashtra.'
        }
    ,
        {
            "title": 'Pune',
            "lat": '18.523600',
            "lng": '73.847800',
            "description": 'Pune is the seventh largest metropolis in India, the second largest in the state of Maharashtra after Mumbai.'
        }
];

我怎样才能做到这一点?

我已经尝试了JsonObject和JsonArray,但仍然显示类似1 Object array的参数,并且无法访问该数组中的数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM