I'm trying to access Wiki api with below query:
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&origin=*&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1
I'm getting response, but when I'm using JSON.parse to parse response Mozilla is displaying an error:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Try this:
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&origin=*&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1&format=json
Add the format=json query parameter. Otherwise you're getting HTML with embedded JSON
Add finally format JSON string in url
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&origin=%2A&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1&format=json
Related
Athena (Trino SQL) parsing JSON document (table column called document 1 in Athena) using fields (dot notation)
If the underlying json (table column called document 1 in Athena) is in the form of {a={b ...
I can parse it in Athena (Trino SQL) using
document1.a.b
However, if the JSON contains {a={"text": value1 ...
the quote marks will not parse correctly.
Is there a way to do JSON parsing of a 'field' with quotes?
If not, is there an elegant way of parsing the "text" and obtain the string in value 1? [Please see my comment below].
I cannot change the quotes in the json and its Athena "table" so I would need something that works in Trino SQL syntax.
The error message is in the form of: SQL Error [100071] [HY000]: [Simba][AthenaJDBC](100071) An error has been thrown from the AWS Athena client. SYNTAX_ERROR: Expression [redacted] is not of type ROW
NOTE: This is not a duplicate of Oracle Dot Notation Question
Dot notation works only for columns types as struct<…>. You can do that for JSON data, but judging from the error and your description this seems not to be the case. I assume your column is of type string.
If you have JSON data in a string column you can use JSON functions to parse and extract parts of them with JSONPath.
I want to insert real time json payload into MySql DB. But I am unable to do so. I am trying to achieve it via mule 4. I am prompted the below error:-
Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
Please help.
MySql DB expects String as parameter in the SQL statement. Your component sends data as object. Word "binary" indicates it.
Send data as String. Convert your JSON object to string as described here https://simpleflatservice.com/mule4/Object_as_string.html
Example:
%dw 2.0
var x={abc:"xyz","key":"value"}
output application/java
---
write(x,'application/json')
List item
I am a newbie in the azure environment. I am getting JSON response from my custom connector but I need to convert that JSON into parameters so I can use these parameters in further actions Can anybody know how is this possible ?
You want to use these parameters in further actions but you don't mention which type it's stored.
1.Stored as string. In this way the whole json is a string, it's not supported to select property. So you need parse it to Json with Parse JSON action then you will be able to select property. About the Parse JSON Schema, just click the Use sample payload to generate schema and paste your json value, it will generate. And select your property just use the #{body('Parse_JSON')?['name']}, it will work.
2.If it's stored as an Object, just use expression variables('test1')['name'] to get it.
I have searched a lot but not found exact slution.
I have a REST service, in response of which I get rows and each row in a JSON, as given bellow:
{"event":"click1","properties":{ "time":"2 dec 2018","clicks":29,"parent":"jbar","isLast":"NO"}}
{"event":"click2","properties":{ "time":"2 dec 2018","clicks":35,"parent":"jbar3","isLast":"NO"}}
{"event":"click3","properties":{ "time":"2 dec 2018","clicks":10,"parent":"jbar2","isLast":"NO"}}
{"event":"click4","properties":{ "time":"2 dec 2018","clicks":9,"parent":"jbar1","isLast":"YES"}}
Each row is a JSON (all are similar to each other). I have a database table having all those fields as columns. I wanted to loop through these and upload all data in Talend. What I have tried is following:
tRestClient--tNormalize--tExtractJsonFields--tOracleOutput
and provided loop criteria and mapping in tExtractJsonFields component but it is not working and throwing me error saying "json can not be null or empty"
Need help in doing that.
Since your webservice returns multiple json objects in the response, it's not valid json but rather a json document.
You need to break it into individual json objects.
You can add a tNormalize between tRESTClient and tExtractJsonFields, and normalize the json document on "\n" character.
The error "json can not be null or empty" is due to an error in your Jsonpath queries. You have to set the loop query to "$", and reference the json properties using "event", "properties.time"
could you try this :
In your tExtractJsonFields, configure the property readBy to JsonPath without loop
I am trying to convert x-www-form-urlencoded into json.
In the form I have a key and a value. Key as a queryFilter and the value corresponding to that. I also have a header as a cookie. When i tried in x-www-form-urlencoded it gives me right response.But it gives me 400 status when i tried as a raw in Json. Can any one please help me convert x-www-form-urlencoded to JSON?