I have the following contract
"shape": {
"type": "MultiPoly",
"points": [
[
[
[
-92.53941242522892,
41.51492979593705
],
[
-92.53942433363545,
41.51493000420402
],
.
.
.
"shape": {
"type": "Poly",
"points": [
[
[
-92.6814794540405,
41.7796968811509
],
[
-92.6820158958435,
41.7801769167539
]
.
.
.
As you can see, MultiPoly has another level in the array hierarchy. How can I create a POJO to successfully parse both cases? Is it possible?
List<List<List<Double>>> points; seems to work but only for Polys.
Thanks,
Otterman
So I was able to figure this out by storing the points in a generic Object [] array and then parsing manually based on the type.
private Object[] points;
Related
**[11:12] Umer Saleem
Working on it, sir in this example link what is the components name and how to find it
POST https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/{component_name}/commands/{command_name}
**
To find out what components you have for this device, you can do a GET request to
https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/
This will show you the components, a sample response can be:
{
"value": [
{
"#id": "urn:machine:MyMachine:lxhc64xu:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_7d7",
"displayName": "Interface"
},
{
"#id": "urn:machine:MyMachine:_lyh_e2x:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_282",
"displayName": "Properties"
}
]
}
The name of the {component} is the name of the value that you get in the response. In my example, you can use "cb_7d7" or "cb_282". They are the names of your interfaces.
I am working on an ionic app which will be used on android and iOS platforms.and I need to post an object to the server which contain some attribute that reference others for example:
{
"room": [
{
"#id": 2,
"date": "2019-10-10",
"number": "750"
}
],
"bed": [
[
{
"class": "A",
"room": 2
}
]
]
}
but when posting it the order of the JSON object changes to :
{
"bed": [
[
{
"class": "A",
"room": 2
}
]
],
"room": [
{
"#id": 2,
"date": "2019-10-10",
"number": "750"
}
]
}
what should I do to keep the order of the object, considering that it works fine in android?
Referring to JSON's standards, an object is simply unordered which means there is no problem with your case. However, if in your case the order is important, you may use arrays. Arrays make sure the order is preserved.
I am trying to fetch JSON Object which has 2 list object with the same name, but has a different value. The object list named "items", the first "items" has "products_title,product_image,link", and the second "items" has "article_title, article_image,link". How to write PODO ?
I've been trying to writes PODO, but even i try to change the model, it still does not work. I try the other REST API, for the example "https://jsonplaceholder.typicode.com/pothos" its working fine. But if i try used my JSON its getting error, i wonder how to write PODO ?
this is the JSON i am using :
{
"data": [
{
"section": "electronics",
"items": [
{
"product_name": "Cellphone",
"product_image": "cellphoneImage.png",
"link": "https://cellphone.html"
},
]
},
{
"section": "facts",
"section_title": "Title section",
"items": [
{
"article_title": "Facts",
"article_image": "https://www.facts.png",
"link": "https://www.facts.html"
},
]
}
]
}
I would like to perform a request to OSM Overpass Turbo API or Overpass API from and Android Application so i can get the buildings around and area using JSON.
Something similar to
http://overpass-turbo.eu/ with the query presented below:
[out:json][timeout:25];
// gather results
(
// query part for: “building”
way["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
relation["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
);
// print results
out body;
>;
out skel qt;
The thing is that i need the results in geojson like the result below but i cannot find any query that gives me the below result.
{
"type": "FeatureCollection",
"generator": "overpass-turbo",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
"timestamp": "2015-03-23T20:41:02Z",
"features": [
{
"type": "Feature",
"id": "relation/2604192",
"properties": {
"#id": "relation/2604192",
"building": "yes",
"type": "multipolygon"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
23.7319885,
37.9752441
],
[
23.7319787,
37.9751612
],
[
23.7319494,
37.9751641
],
[
23.7319372,
37.9748376
],
[
23.7319702,
37.9748318
],
]
]
}
},
I get only results with nodes but not with geometry.
{
"type": "way",
"id": 25107859,
"nodes": [
2373953582,
2373953586,
2373953592,
2373953599,
2373953597,
2373953636,
2373953633,
2373953626,
273319309,
2373953582
],
"tags": {
"building": "yes"
}
},
After some useful comments (thanks scai) i found out that overpass turbo is not queried automatically. Therefore i searched for overpass api and i found out this site with a query for buildings to overpass api exporting to GeoJSON but i does not work (though the xml query in the site works but i need json). Anyone has a query that works so i can follow it?
http://inasafe.org/en/developer-docs/osm_building_downloads.html
http://overpass-api.de/api/interpreter?data=[out:json];(node[%23building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);way[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);relation[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725););(._;%3E;);out%20body;
I need to map a JSON object to a class using GSON, here is the JSON object:
{
"protocols": [
[ "https", 39 ],
[ "http", 1 ]
],
...
}
Generally if there are entity names specified it is easy to do something like this:
{
"protocols": [
[ "name":"https", "count":39 ],
[ "name":"http", "count":1 ]
],
...
}
class ProtocolItem {
#SerializedName("name")
String protocolName;
#SerializedName("count")
int count;
}
However since no entity names are specified in this case, I am not sure how to do the mapping for this. Please point some directions for me if you are familiar with the case.
Thanks
Unlike your first example,
[ "name":"https", "count":39 ],
is invalid JSON as you can either specify an array using [1, 2] without any names or a map using {"x": 1, "y": 2} with "entity names" as keys. So the solution is simple:
{
"protocols": [
[ "https", 39 ],
[ "http", 1 ]
],
}
is a map with a single key and a value which is an array of arrays of objects. You can map it as
class All {
Object[][] protocols;
}
You must use Object here, as it needs to accept both strings and ints. Instead of arrays, you can use Lists.
I guess, you'd prefer to serialize it as
class All {
Map<String, Integer> protocols;
}
This is possible, too, but you need a TypeAdapter. The very first linked example shows clearly how to do it (start with beginArray, in a loop test JsonToken.BEGIN_ARRAY and do nextString and nextInt, etc.).