["from": /topics/nursery-a, "is_background": false, "flag": 1, "data": {"msg_head_id":{"msg_head_id":7,"name":"Section","created_at":"2017-01-24 19:34:43"},"msg_title":"hello","message":{"msg_head_id":7,"doc_url":"","msg_title":"hello","created_at":"2017-02-24 10:11:07","message_id":225,"message":"welcome"},"user":{"user_id":57,"gcm_registration_id":"","name":"Iron","created_at":"2016-12-27 12:41:18","email":"info#mail.in"}}, "title": Smart , "collapse_key": do_not_collapse]
it's not a valid JSON. it should be start and close with { and }, remove [ and ], also quotation mark is missing. After these changes try this in http://json.parser.online.fr/
According to the official site, json is built on two structures -- which named dictionary and array in iOS.
So this json output isn't valid json. The value of a json key should be one of array/object(key value pairs)/number/string/boolean/null.
The from, title, collapse_key should boxed in "" to be a string.
And the json output should start and end with {} not [].
Related
In power automate using Invoke an HTTP request, I am unable to make a graph API call for email sent(Post: https://graph.microsoft.com/v1.0/me/sendMail) with a customized email body (HTML elements and tags). It does not allow the below custom HTML code and errors as "Unable to read JSON request payload. Please ensure the Content-Type header is set and payload is of valid JSON format." Please find the code below. In addition, HTML code is
Please find the code below.
And HTML Code is
This error occurs because your payload is not in a valid json format. You have to escape the quotation marks. Use \" intead of ".
{
"data": "<html><head>The title attribute example</head><body><h3 title=\"Hello HTML!\">Titled head tag example</h3></body></html>"
}
Like #Optimal already mentioned. It is good to escape the quotation marks of the HTML Body value.
However, I see the request body also has a saveToSentItems boolean property. Can you try it with that boolean as well?
Try something like below:
{
"message": {
"subject": "#{triggerBody()['text']}",
"body": {
"contentType": "HTML",
"content": "#{triggerBody()['text_1']}"
},
"toRecipients": [
{
"emailAddress": {
"address": "#{triggerBody()['text_2']}"
}
}
]
},
"saveToSentItems": "true"
}
First time trying to use the Ruby AWS ADK V2 and I am trying to format the data i am getting back and it seems quiet hard getting it into useable format.
All I want to do is get a list of Hosted Zones and display in a table.
I have a helper that has:
def hosted_zones
r53 = Aws::Route53::Client.new
#convert to hash first so we can parse and covert to json
h = (r53.list_hosted_zones).to_hash
j = JSON.parse((h.to_json))
end
which then returns me the following JSON:
{
"hosted_zones": [{
"id": "/hostedzone/Z1HSDGASSSME",
"name": "stagephil.com.",
"caller_reference": "2016-07-12T15:33:45.277646707+01:00",
"config": {
"comment": "Private DNS zone for stage",
"private_zone": true
},
"resource_record_set_count": 10
}, {
"id": "/hostedzone/ZJDGASSS0ZN3",
"name": "stagephil.com.",
"caller_reference": "2016-07-12T15:33:41.290143511+01:00",
"config": {
"comment": "Public DNS zone for stage",
"private_zone": false
},
"resource_record_set_count": 7
}],
"is_truncated": false,
"max_items": 100
}
To which I am running a really but while statement to interact through all the hosted_zone entries into a table.
Is this the best way to get the response or can you request the response to be json already?
Why are you converting a hash to JSON, only to convert it to a hash again? JSON.parse(some_hash.to_json) will just give you some_hash.
That being said, I don't think it is possible to get JSON directly from AWS, mainly due to the fact that their API responds with XML. I think that your solution is ideal if that's all you're doing, but if you want, you can make a request with an HTTP client and then take the XML that you receive and use something like ActiveSupport's Hash.from_xml to create a hash that you can then convert to JSON.
Is it true CKAN DataStore is able to deal with GeoJson? I've not seen any reference in the documentation except for this link about the DataStore Map visualization, saying:
Shows data stored on the DataStore in an interactive map. It supports plotting markers from a pair of latitude / longitude fields or from a field containing a GeoJSON representation of the geometries.
Thus, I'm supossing GeoJson is accepted in DataStore columns. Anyway, I've not found any GeoJson CKAN type, thus, again, I'm guessing the simple Json type must be use for this purpose.
Can anybody confirm this? Thanks!
EDIT 1
I've created a resource and a datastore and a "recline_map_view" associated to the resource. Then, I've upserted a value, which is shown by this datastore_search operation:
$ curl -X POST "https://host:port/api/3/action/datastore_search" -d '{"resource_id":"14418d40-de42-4fdd-84f7-3c51244c7469"}' -H "Authorization: xxx" -k
{"help": "https://host:port/api/3/action/help_show?name=datastore_search", "success": true, "result": {"resource_id": "14418d40-de42-4fdd-84f7-3c51244c7469", "fields": [{"type": "int4", "id": "_id"}, {"type": "text", "id": "label"}, {"type": "json", "id": "geojson"}], "records": [{"_id": 1, "geojson": {"type": "Point", "coordinates": [48.856699999999996, 2.3508]}, "label": "Paris"}], "_links": {"start": "/api/3/action/datastore_search", "next": "/api/3/action/datastore_search?offset=100"}, "total": 1}}
Nevertheless, nothing is shown in CKAN :(
EDIT 2
It was a problem with my CKAN. I've tested Ifurini's solution at demo.ckan.org and it works.
GeoJSON is just a (particular kind of) JSON, so it does not have a particular treatment as a database field.
So, you can create a resource with a GeoJSON field from a simple CSV file like this:
Name,Position
"Paris","{""type"":""Point"",""coordinates"":[2.3508,48.8567]}"
(note the double double quotes "" instead of just a single double quote ")
If you call the column "GeoJSON" (or "geojson", "gEoJsOn", etc., as capitalization is not important) the Map View will automatically use that field to mark the data in the map, instead of just letting you manually select which field to use.
I obtained some badly written JSON file that's totally not readable through any AFNetworking and/or any other JSON serializing library. I must underline that I am not able to force to change it on server-side so I have to parse it as is.
Unfortunately it has some minor errors (I will paste small part of it):
locations = [{
"city": "Tokio",
(...)
"link": "http://somethig.com",
"text": "Mon-Fr.",
}, {
(... same repeated mistakes, but they're not regular)
}]
Aaand to parse it correctly in XCode i need to change it to correct format e.g.:
{
"locations": [{
"city": "Tokio",
(...)
"link": "http://somethig.com",
"text": "Mon-Fr."
}, {
(...)
}]
}
Do you have any idea how to deal with that?
If I will have to write my own parser - please advice me how to. Any help will be appreciated. I download this JSON from http link.
It looks like the API is sending you a string of JavaScript code. In JavaScript, you would use JSON.stringify() to convert the object to valid JSON. Here's an example from an interactive node.js shell:
> locations = [{
... "city": "Tokio",
... "link": "http://somethig.com",
... "text": "Mon-Fr.",
... }]
[ { city: 'Tokio', link: 'http://somethig.com', text: 'Mon-Fr.' } ]
> JSON.stringify(locations)
'[{"city":"Tokio","link":"http://somethig.com","text":"Mon-Fr."}]'
If you really can't change this on the server side, you might try creating a hidden UIWebView, adding the JavaScript, calling JSON.stringify(), and extracting the result. However, this will use many more resources than are needed. It would be much better (in terms of computing power, memory, and your time) to have the API call JSON.stringify() and send you a valid JSON string.
You could also try porting some of json3.js to Objective-C or Swift. I would start with the section beginning // Public: `JSON.stringify`. if you attempt this.
I have returned json array like:
{key:123,value:"Kyiv"},
{key:5675,value:"Ukraine"},
{key:456,value:"Poland"}
I need to find names in value field, but after clicking on some value to input line must be added only key value.
P.S. Sorry if i created dublicate question, but i can not find solution on this site. If related thread isset, please give me link, please.
The JSON Object you provided is invalid in his syntax ! Your key should be a string. Furthermore those are 3 JSON Objects autosuggest only takes one you should wrapp that in an array. You can simply check if your JSON is valid on http://jsonlint.com/. Your valid syntax would be:
[
{
"key": 123,
"value": "Kyiv"
},
{
"key": 5675,
"value": "Ukraine"
},
{
"key": 456,
"value": "Poland"
}
]