I have a nested json array as follows:
When I try to post this I am getting the error messages:
{"RestFaultElement":{"summary":"Translation Failure.\nFailed to translate JSON to XML. java.io.IOException: Array start inside array\nThe incoming data does not conform to the NXSD schema. Please correct the problem.\n","code":null,"detail":null}}
"Options": {
"Co-ordinates": {
"X": "594752",
"Y": "714430"
},
"Language": "English",
"PageSize": "A4",
"Scale": "1,000",
"Orientation": "Landscape",
"GeometryData": {
"type": "polygon",
"rings": [
[
[
716102.6700605,
733105.7692149
],
[
716431.41550966,
733105.7692149
],
[
716431.41550966,
732878.22709315
],
[
716102.6700605,
732878.22709315
],
[
716102.6700605,
733105.7692149
]
]
],
"_ring": 0,
"spatialReference": {
"wkid": 2157,
"latestWkid": 2157
},
"cache": {
"_extent": {
"xmin": 717192,
"ymin": 733058.86,
"xmax": 717424,
"ymax": 733230.86,
"spatialReference": {
"wkid": 2157,
"latestWkid": 2157
}
},
"_partwise": "PARTWISE",
"_centroid": {
"type": "point",
"x": 717308.00000013,
"y": 733144.86000007,
"spatialReference": {
"wkid": 2157,
"latestWkid": 2157
}
}
}
}
The problem part of this seems to be with the "rings" array.
I believe that 1 of 2 things is happening:
1. The JSON syntax is wrong.
2. The xsd file is set up wrong.
The XSD segments which should accept this element is defined as:
<xsd:element type="xsd:decimal" name="rings"/>
Would this set up allow for an array like so to be passed to it?
Thank you.
You are missing brackets at start end end of your string. Try:
{"rings": [
[
[
716102.6700605,
733105.7692149
],
[
716431.41550966,
733105.7692149
],
[
716431.41550966,
732878.22709315
],
[
716102.6700605,
732878.22709315
],
[
716102.6700605,
733105.7692149
]
]
]}
Related
This question already has answers here:
Error "RangeError: minimumFractionDigits value is out of range" with ChartJS in Next.js app
(3 answers)
Closed 4 months ago.
everthing is working fine in development on my local machine,
but when I deploy my site to netlify, I get this wierd error in console.
the page data is gotten using getStaticProps function and then passed to the page as props.
here is how the data looks like
[
[ 17671, 19856, 37527 ], [ 4887, 5418, 10305 ],
[ 2803, 2303, 5106 ], [ 8617, 9403, 18020 ],
[ 12664, 15722, 28386 ], [ 4227, 3359, 7586 ],
[ 1371, 1545, 2916 ], [ 17526, 14297, 31823 ],
[ 6883, 4781, 11664 ], [ 9805, 10000, 19805 ],
[ 11068, 12888, 23956 ], [ 4570, 4722, 9292 ],
[ 15428, 17309, 32737 ], [ 3565, 3656, 7221 ],
[ 8750, 10443, 19193 ], [ 1771, 1432, 3203 ],
[ 8495, 9979, 18474 ], [ 288, 265, 553 ],
[ 21130, 19321, 40451 ], [ 6867, 6556, 13423 ],
[ 2656, 2092, 4748 ], [ 967, 656, 1623 ],
[ 4540, 4505, 9045 ], [ 7025, 7108, 14133 ],
[ 53134, 59829, 112963 ], [ 8640, 9028, 17668 ],
[ 6759, 7119, 13878 ], [ 28803, 31362, 60165 ],
[ 7346, 7630, 14976 ], [ 9771, 10963, 20734 ],
[ 15783, 17397, 33180 ], [ 9847, 9706, 19553 ],
[ 15154, 17577, 32731 ], [ 1056, 874, 1930 ],
[ 3260, 2476, 5736 ], [ 1488, 1424, 2912 ],
[ 1656, 1154, 2810 ]
]
it is an array of arrays of 3 numbers.
please how do I solve this?
You need to set swcMinify: false false in your next.confug.js. This is currently a bug in the swcMinifier and you will need to wait until they have fixed it before you can enable it again.
I have a project where I need to check inside which municipalities a certain road is inside. In order to do so I check this using the ST_Intersects function provided by PostGIS.
The problem that I am facing is that I keep on getting errors when using the roads in the querybuilder of typeorm.
My first attempt gave me the following error QueryFailedError: ST_Intersects: Operation on mixed SRID geometries (MultiPolygon, 4326) != (LineString, 0) at new QueryFailedError:
const municipalities = await getConnection()
.getRepository(Municipality)
.createQueryBuilder('municipality')
.where('ST_Intersects(municipality.polygon, :lineString)', { lineString: feature.geometry })
.getQueryAndParameters()
Then I tried to fix this by setting the CRS of the Linestring using ST_SetSRID function that is also provided by PostGIS. But this gives me the following error QueryFailedError: function st_setsrid(unknown, integer) is not unique:
const municipalities = await getConnection()
.getRepository(Municipality)
.createQueryBuilder('municipality')
.where('ST_Intersects(municipality.polygon, ST_SetSRID(:lineString, 4326))', { lineString: feature.geometry })
.getMany()
I have also tried to transfer the Geojson object using ST_GeomFromGeoJSON function in PostGIS. But this gives me the following error: QueryFailedError: quoted object property name expected (at offset 1):
const municipalities = await getConnection()
.getRepository(Municipality)
.createQueryBuilder('municipality')
.where('ST_Intersects(municipality.polygon, ST_GeomFromGeoJSON(:lineString))', { lineString: feature.geometry.coordinates })
.getMany()
I have tried to see if the problem was when inserting the linestring into the query. I did this by using the getQueryAndParameters return function of typeorm:
[
'SELECT "municipality"."uuid" AS "municipality_uuid", "municipality"."name" AS "municipality_name", ST_AsGeoJSON("municipality"."polygon")::json AS "municipality_polygon" FROM "municipality" "municipality" WHERE ST_Intersects("municipality"."polygon", ST_SetSRID($1, 4326))',
[ { type: 'LineString', coordinates: [Array] } ]
A Linestring object in looks as follows:
{
type: 'LineString',
coordinates: [
[ 3.2188848, 51.1980164 ],
[ 3.2190236, 51.1981144 ],
[ 3.2190737, 51.1981991 ],
[ 3.2191065, 51.1982793 ],
[ 3.2191314, 51.1983772 ],
[ 3.2191128, 51.1984885 ],
[ 3.2192215, 51.1985207 ],
[ 3.2192447, 51.1985056 ],
[ 3.219269, 51.1985136 ],
[ 3.2193766, 51.1985571 ],
[ 3.2194258, 51.1985769 ],
[ 3.2194638, 51.198697 ],
[ 3.2195437, 51.1987221 ],
[ 3.2196618, 51.1987591 ],
[ 3.219529, 51.1989397 ],
[ 3.2195909, 51.1990766 ],
[ 3.2196759, 51.1992964 ],
[ 3.2197817, 51.1993408 ],
[ 3.2199103, 51.1992987 ],
[ 3.2204127, 51.1991677 ],
[ 3.2208458, 51.199056 ],
[ 3.2211454, 51.1989993 ],
[ 3.2217751, 51.1988675 ],
[ 3.2219908, 51.1988136 ],
[ 3.2223186, 51.1987693 ],
[ 3.2223696, 51.1987867 ],
[ 3.2223974, 51.1987845 ],
[ 3.2225339, 51.1987696 ],
[ 3.2230863, 51.1987062 ],
[ 3.2233638, 51.198683 ],
[ 3.2234618, 51.1986505 ],
[ 3.223517, 51.1986535 ],
[ 3.2235298, 51.1986528 ],
[ 3.2236432, 51.198651 ],
[ 3.2243337, 51.1986565 ],
[ 3.2244463, 51.198654 ],
[ 3.2245644, 51.1986568 ],
[ 3.2249334, 51.1986506 ],
[ 3.2249647, 51.1986493 ],
[ 3.2251107, 51.19867 ],
[ 3.225378, 51.1986779 ],
[ 3.2257131, 51.1987153 ],
[ 3.225936, 51.1987341 ]
]
}
I have found an answer. ST_GeomFromGeoJSON was indeed the wright function to use in order to inject a GeoJSON object into the query. But I had accidentally used the coordinates instead of the full GeoJSON object.
So the solution is:
const municipalities = await getConnection()
.getRepository(Municipality)
.createQueryBuilder('municipality')
.where('ST_Intersects(municipality.polygon, ST_GeomFromGeoJSON(:lineString))', { lineString: feature.geometry })
.getMany()
I need to convert the following array data to Json in react.
I tried map method, but it is not the correct way. I need key value pair, so that i can pass it to server as json
[
[
"channel",
"s1"
],
[
"category",
"Account 1"
],
[
"accountAdministration",
"Partnership 1"
],
[
"partnershipAccounting",
"1 level Performance issues"
],
[
"requestCategory",
"Research"
],
[
"severity",
"Blocker"
],
[
"activationDate",
"2020-10-29T05:54:00.000Z"
],
[
"managerApproved",
true
]
]
Try using reduce and creating an object:
var arr = []; // your array
var data = arr.reduce((map, item) => {
map[item[0]] = item[1];
return map;
}, {});
The data object will be in the following format:
{
"accountAdministration": "Partnership 1",
"activationDate": "2020-10-29T05:54:00.000Z",
"category": "Account 1",
"channel": "s1",
...
}
Worked with
Object.fromEntries([
[
"channel",
"s1"
],
[
"category",
"Account 1"
],
[
"accountAdministration",
"Partnership 1"
],
[
"partnershipAccounting",
"1 level Performance issues"
],
[
"requestCategory",
"Research"
],
[
"severity",
"Blocker"
],
[
"activationDate",
"2020-10-29T05:54:00.000Z"
],
[
"managerApproved",
true
]
])
I am trying to check the last status of an ECS task, if it is STOPPED then it has to trigger lambda using cloudwatch event. I am getting below error message while validating the JSON event.
Error message:
Event pattern contains invalid element (can only be Strings enclosed in quotes, numbers, and the unquoted keywords true, false, and null)
**Code**:
{
"source": [
"aws.ecs"
],
"detail-type": [
"ECS Task State Change"
],
"detail": {
"clusterArn": [
"arn:aws:ecs:us-west-2:17025:cluster/ecs-w2"
],
"lastStatus": [
"STOPPED"
],
"overrides": {
"containerOverrides":
{
"environment":
{
"name": ["job_grp_nm"],
"value": ["QA_INTEGRATION"]
},
{
"name": ["secrets_targetdb"],
"value": ["7034908/Snowflake/facilitiesNDI/QA"]
},
"name": ["suite-dev"]
}
}
}
}
Please let me know what's wrong with the code.
There are two things wrong:
The values should be expressed as array of string, e.g. ["value"]
Your environment can be an array of objects.
So it should be:
{
"source": [
"aws.ecs"
],
"detail-type": [
"ECS Task State Change"
],
"detail": {
"clusterArn": [
"arn:aws:ecs:us-west-2:17025:cluster/ecs-w2"
],
"lastStatus": [
"STOPPED"
],
"overrides": {
"containerOverrides":
{
"environment":
{
"name": ["job_grp_nm"],
"value": ["QA_INTEGRATION"]
},
"name": ["suite-dev"]
}
}
}
}
The above should be accepted, but I can't verify if this will correctly match your event.
I'm trying to parse JSON which is like below:
"price": [
[
1539283140000,
6288.07
],
[
1539283440000,
6285.82
],
[
1539283740000,
6285.81
],
[
1539284041000,
6280.37
],
[
1539284340000,
6280.19
]
Please help me deal with this. And is there a possibility to decode the timestamp value to a date.
Correct json
{
"price": [
[
1539283140000,
6288.07
],
[
1539283440000,
6285.82
],
[
1539283740000,
6285.81
],
[
1539284041000,
6280.37
],
[
1539284340000,
6280.19
]
]
}
struct Root: Codable {
let price: [[Double]]
}
let res = try? JSONDecodable().decode(Root.self,from:jsonData)