Related
I have a json schema that marks special properties in need of processing and I want to query those via JsonPath.Evaluate.
Here's a part of the schema to illustrate the issue
{
"type": "object",
"properties": {
"period": {
"description": "The period in which the rule applies",
"type": "object",
"properties": {
"start": {
"type": "string",
"format": "date-time"
},
"end": {
"type": "string",
"format": "date-time"
}
},
"required": [
"start"
],
"x-updateIndicatorProperties": [
"start"
]
},
"productType": {
"type": "string"
},
"x-updateIndicatorProperties": [
"productType"
]
}
}
I want to get the the JsonPath of the "x-updateIndicatorProperties" properties, so that I can then query the actual properties to process.
For this example, the expected result would be
[
"$['properties']['x-updateIndicatorProperties']",
"$['properties']['period']['x-updateIndicatorProperties']"
]
I've been trying for a while to get a JsonPath expression that would query these properties.
Currently I'm just iterating all properties and filter them manually :
"$..*"
I've also tried using :
$..['x-updateIndicatorProperties']
This works. But it returns a lot of duplicates. For the example above, I get 5 results instead of the expected 2. Can be demonstrated here : https://json-everything.net/json-path
Assuming I can't influence the schema itself, only the code that traverses it,
can anybody help with an expression to get the expected results or any other way to achieve the same outcome?
The stack is JsonPath 0.2.0, .net 6 and system.text.json.
This was a bug in the library when parsing paths that use a recursive descent (..) into a quoted-property-name selector (['foo']). So it would happen for any path in the form $..['foo'].
I've fixed the issue and released version 0.2.1.
Dear Stackoverflow team,
I'm impressed that after a bunch of hours digging the forum I still can't find any question/answer similar to my problem :
I have a GeoJson with a lot of Points features. I collect all Points (green in my example, see figure below) that follow some specification (distance between each of them)
Initial Data:
and I want to link all of them to build a Polygon (which represent an area).
What I'm looking for :
Or Solution accepted :
So I collect all coordinates from these Points, and to be sure the Polygon follows the GeoJson requirements, I'm using the "rewind" function
from geojson_rewind import rewind
But at the end, whatever I've tried I only get that kind of Polygon:
I probably don't use correctly the "rewind" function?
I'm looking for an (easy) automatic way to link all points together in a "convexion hull"
Thanks a lot for any help !
My initial coordinates are collected in a list :
[[4.3556672, 50.8538851], [4.3542534, 50.8546955], [4.3567798, 50.8547854], [4.3566527, 50.8541356], [4.3574286, 50.8552813], [4.3572234, 50.8551264], [4.3547752, 50.8545063], [4.3572736, 50.8560176], [4.3571226, 50.8546104]]
and the Polygon GeoJson I've managed to build, with the rewind function (recopying the last coordinates to get a Polygon) looks like that :
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
4.357223,
50.855126
],
[
4.35678,
50.854785
],
[
4.355667,
50.853885
],
[
4.356653,
50.854136
],
[
4.357123,
50.85461
],
[
4.354253,
50.854695
],
[
4.354775,
50.854506
],
[
4.357429,
50.855281
],
[
4.357274,
50.856018
],
[
4.357223,
50.855126
]
]
]
}
}
]
}
The shapely library is very useful for doing these kinds of geometric manipulations.
For generating a polygon of the convex hull of a set of geometries you can use object.convex_hull:
import shapely.geometry as sg
points = [[4.3556672, 50.8538851], [4.3542534, 50.8546955], [4.3567798, 50.8547854], [4.3566527, 50.8541356], [4.3574286, 50.8552813], [4.3572234, 50.8551264], [4.3547752, 50.8545063], [4.3572736, 50.8560176], [4.3571226, 50.8546104]]
polygon = sg.MultiPoint(points).convex_hull
Which results in the following shape:
Converting it into a GeoJSON with the help of shapely.geometry.mapping:
feature_collection = {
"type": "FeatureCollection",
"features": [
{"type": "Feature", "properties": {}, "geometry": sg.mapping(polygon)}
],
}
import json
geojson = json.dumps(feature_collection)
I like to use curl to fetch data from my application insights but i'm unable to get the data from customDimensions (which contains json data). A simple query would be this one:
curl "https://api.applicationinsights.io/v1/apps/my-app-id/query?query=traces%20%7C%20project%20customDimensions" -H "x-api-key: my-api-key"
Let's assume the traces table contains 10 entries then the response would look like this:
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "customDimensions",
"type": "dynamic"
}
],
"rows": [
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ],
[ null ]
]
}
]
}
Using the query editor in application insights in the azure portal, the same query works fine and returns the customDimensions.
Thanks in advance.
Could you please check the application insights you used in your curl query is the same one you did in query editor in azure portal?
I test it at my side, no problem.
Can you try this portal to query application insight from cURL-
https://dev.applicationinsights.io/apiexplorer/query.
In the Request tab choose cURL and in the query tab just write traces | project customDimensions. It worked for me.In that way you can be sure that querying from cURL will work.
I've set up a very simple script and part of it requires a yes or no response from the user.
When I test the script through the script builder at ibmwatsonconversation.com the script works fine.
But when I'm testing it through Postman making HTTP POST requests when I get to the part that requires a yes or no answer the output node is always
"output": {
"log_messages": [],
"text": [],
"nodes_visited": [
"node_25_1480610375023"
]},
The previous two nodes in the conversation work fine.
I have set up intents for yes and no, see images below:
The dialog is as follows:
Here's the chain of requests / responses:
{"input": {"text": "hello"}}
"output": {"log_messages": [],"text": ["Welcome to the KMBC IT help desk.How can I help you?"],"nodes_visited": ["node_1_1480509441272"]},
then
{"input": {"text": "my laptop is broken"}}
"output": {
"log_messages": [],
"text": [
"I'm sorry to hear that your laptop isn't working. \n\nI need you to check a couple of things for me, is that ok?"
],
"nodes_visited": [
"node_3_1480509642420",
"node_19_1480518011225"
]},
finally
{"input": {"text": "yes"}}
"output": {
"log_messages": [],
"text": [],
"nodes_visited": [
"node_25_1480610375023"
]},
Works fine inside the "Try it out" panel within the workspace:
Full JSON request / response:
{"input": {"text": "hello"}}
{"intents": [{"intent": "greetings","confidence": 1}],"entities": [],"input": {"text": "hello"},"output": {"log_messages": [],"text": ["Welcome to the KMBC IT help desk. How can I help you?"],"nodes_visited": ["node_1_1480509441272"]},"context": {"conversation_id": "4b5b1858-ae4e-4907-a3ab-c49abf601fd3","system": {
"dialog_stack": [
{
"dialog_node": "root"
}
],
"dialog_turn_counter": 1,
"dialog_request_counter": 1
}}}
{"input": {"text": "laptop broken"}}
{"intents": [{"intent": "complaint","confidence": 0.989692384334575}],"entities": [
{"entity": "hardware",
"location": [
0,
6
],
"value": "laptop"
}],"input": {"text": "laptop broken"},"output": {"log_messages": [],"text": ["I'm sorry to hear that your laptop isn't working. \n\nI need you to check a couple of things for me, is that ok?"],"nodes_visited": ["node_3_1480509642420",
"node_19_1480518011225"]},"context": {
"conversation_id": "b53dff12-9252-4b7e-abe8-7b45f561d394",
"system": {"dialog_stack": [{"dialog_node": "node_19_1480518011225"}],
"dialog_turn_counter": 1,
"dialog_request_counter": 1}}}
{"input": {"text": "yes"}}
{"intents": [{"intent": "yes","confidence": 1}],"entities": [],"input": {"text": "yes"},"output": {"log_messages": [],"text": [],"nodes_visited": ["node_25_1480610375023"]},"context": {"conversation_id": "b9ddc5b0-5f3c-423f-9bbe-5a1ef013c175","system": {"dialog_stack": [{"dialog_node": "root"}],"dialog_turn_counter": 1,"dialog_request_counter": 1}}}
Based on the full JSON request/response, your issue is here (actually it's also in the previous call, but that works by concidence):
{"input": {"text": "yes"}}
Conversation is stateless, so you need to send back in the context object you received previously. Otherwise the system doesn't know where to continue. The following request object should look like this:
{
"input": {"text": "yes"},
"context": {
"conversation_id": "b53dff12-9252-4b7e-abe8-7b45f561d394",
"system": {
"dialog_stack": [{"dialog_node": "node_19_1480518011225"}],
"dialog_turn_counter": 1,
"dialog_request_counter": 1
}
}
I would recommend to use the Watson Developer Cloud SDK to manage this for you.
https://github.com/watson-developer-cloud
Have you actually created a yes and no intent ?
There is a lot of debate about the best process to handle yes and no responses. But I have found that by creating a yes and no intent, with example "yes" and "No" responses works well.
Your example questions for these intents could include responses like "ok", "yess", "on no","yes please" etc.
First things first: is this data in proper GeoJSON format?
According to the definition of GeoJSON data, as you can see by the MultiPoint & coordinates, I think it is.
It looks like this:
{
"lang": {
"code": "en",
"conf": 1.0
},
"group": "JobServe",
"description": "Work with the data science team to build new products and integrate analytics\ninto existing workflows. Leverage big data solutions, advanced statistical\nmethods, and web apps. Coordinate with domain experts, IT operations, and\ndevelopers. Present to clients.\n\n * Coordinate the workflow of the data science team\n * Join a team of experts in big data, advanced analytics, and visualizat...",
"title": "Data Science Team Lead",
"url": "http://www.jobserve.com/us/en/search-jobs-in-Columbia,-Maryland,-USA/DATA-SCIENCE-TEAM-LEAD-99739A4618F8894B/",
"geo": {
"type": "MultiPoint",
"coordinates": [
[
-76.8582049,
39.2156213
]
]
},
"tags": [
"Job Board"
],
"spider": "jobserveNa",
"employmentType": [
"Unspecified"
],
"lastSeen": "2015-05-13T01:21:07.240000",
"jobLocation": [
"Columbia, Maryland, United States of America"
],
"identifier": "99739A4618F8894B",
"hiringOrganization": [
"Customer Relation Market Research Company"
],
"firstSeen": "2015-05-13T01:21:07+00:00"
},
I want to visualize this as a "zoomable",viz. interactive, map, as in the examples on the d3js website.
I'm trying to use a tool called mapshaper.org to see an initial visualization of the data in map form, but when I load it up, nothing happens.
To me this doesn't make sense because, according to their website, one can simply
Drag and drop or select a file to import.
Shapefile, GeoJSON and TopoJSON files and Zip archives are supported.
However, in my case it is not working.
Does anyone have any intuition as to what might be going wrong, or a suggestion as to a tool comparable to create a zoomable map out of GeoJSON data?
According to the definition of GeoJSON data, I have what I think constitutes data in that format
Well, you don't have a proper GeoJSON object. Just compare what you've got against the example you've linked. It doesn't even come close. That's why mapshaper doesn't know what to do with the JSON you load into it.
A GeoJSON object with the type "FeatureCollection" is a feature collection object. An object of type "FeatureCollection" must have a member with the name "features". The value corresponding to "features" is an array. Each element in the array is a feature object as defined above.
A feature collection looks like this:
{
"type": "FeatureCollection",
"features": [
// Array of features
]
}
http://geojson.org/geojson-spec.html#feature-collection-objects
A GeoJSON object with the type "Feature" is a feature object. A feature object must have a member with the name "geometry". The value of the geometry member is a geometry object as defined above or a JSON null value. A feature object must have a member with the name "properties". The value of the properties member is an object (any JSON object or a JSON null value). If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name "id".
A feature looks like this:
{
"id": "Foo",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
},
"properties": {
"label": "My Foo"
}
}
http://geojson.org/geojson-spec.html#feature-objects
Here are examples of the different geometry objects a feature can support: http://geojson.org/geojson-spec.html#appendix-a-geometry-examples
Put those two together, it would look like this:
{
"type": "FeatureCollection",
"features": [{
"id": "Foo",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [0, 0]
},
"properties": {
"label": "My Foo"
}
},{
"id": "Bar",
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[100.0, 0.0],
[101.0, 1.0]
]
},
"properties": {
"label": "My Bar"
}
}]
}
That really doesn't look like the JSON you've posted. You'll need to convert that to proper GeoJSON somehow via a custom script or manually. It's a format i've never seen before, sorry to say.