The Newline delimited JSON file parsing correctly for below JSON Structure.
{
"name": "Honeywell",
"BOM": "12 GENUINE MIX RESISTOR KIT 150PCS 30\n1/21/4W + MIX zelatin CAPACITOR KIT\n3",
"url": "http://fairchild.com",
"image": "http://fairchild.com/over.jpg",
"ThresholdRange": "2M",
"Peak": "8",
"date": "2003-04-01",
"DeadTime": "15M"
},
But As soon i am adding below line it is throwing Error.
{
"name": "VishayElectronics.com",
"BOM": "12 GENUINE MIX RESISTOR KIT 150PCS 30\n1/21/4W + MIX power CAPACITOR KIT\n3",
"url": "http://vishay.com",
"image": "http://vishay/to.jpg",
"ThresholdRange": "10M",
"Peak": "8",
"date": "2011-06-06",
"DeadTime": "6M"
}
i am validating using https://jsonlint.com/
Error: Parse error on line 10:
...adTime": "15M"}{ "name": "VishayEl
--------------------^
Expecting 'EOF', '}', ',', ']', got '{'
May someone please help me what changes i should make to resolve error.
Many Thanks.
You lost a "," between your first object and the second one.
Related
I've filtered values in a json file that I obtained from Google Maps API with the following command:
jq '.[] | select(.vicinity|contains("Bern"))' Bern.json > Bern_test.json
(I only want to have places in Bern)
I tried loading the Bern_test.json file to Tableau to visualize it, but Tableau complains that the format is wrong. json validator online also says something is wrong:
Error: Parse error on line 38:
... Wohlen bei Bern"} { "business_status"
----------------------^
Expecting 'EOF', '}', ',', ']', got '{'
Here is the "broken" part (if it helps):
"reference": "ChIJ-abNilA5jkcRAh6Jj7dLx_c",
"scope": "GOOGLE",
"types": [
"restaurant",
"food",
"point_of_interest",
"establishment"
],
"vicinity": "Aumattweg 22, Wohlen bei Bern"
} {
"business_status": "OPERATIONAL",
"geometry": {
"location": {
"lat": 46.9684408,
"lng": 7.377661100000001
I don't know why it got broken, or how I can properly save a json file after I've done some magic with jq. Can anyone help?
Your current filter produces a stream of JSON objects rather than a single JSON value. To fix that, wrap your filter in [...]:
jq '[.[] | select(.vicinity|contains("Bern"))]' Bern.json > Bern_test.json
or use the predefined map function to achieve the same result.
jq 'map(select(.vicinity|contains("Bern")))' Bern.json > Bern_test.json
I tried to view my JSON file as a tree and I got an error that I don't know how to solve.
error:
Parse error on line 1: ...2","Likes":"0/0"}} {"Id":2,"commContent ----------------------^ Expecting 'EOF', '}', ',', ']', got '{'
JSON output:{"Id":1,"commContent":{"Name":"username1","Comment":"text1","Date":"5.5.2021 10:22","Likes":"0/0"}} {"Id":2,"commContent":{"Name":"username2","Comment":"text2","Date":"5.5.2021 10:24","Likes":"0/0"}}
Json online editor Iam using: https://jsoneditoronline.org/#
There is a problem with the JSON you have produced. You have two distinct elements in the JSON but they are not in an array, so the tree looks like this:
Root element
Root element
The error messages is correctly identifying the problem - it is expecting EOF but instead is receiving a new element starting with {.
That doesn't make any sense - the elements probably need to be nested in an array (surrounded with [] and with a comma , between), like this:
[
{
"Id": 1,
"commContent": {
"Name": "username1",
"Comment": "text1",
"Date": "5.5.2021 10:22",
"Likes": "0/0"
}
},
{
"Id": 2,
"commContent": {
"Name": "username2",
"Comment": "text2",
"Date": "5.5.2021 10:24",
"Likes": "0/0"
}
}
]
The above would be considered valid.
I'm using Talend ETL Tool and extracting data from json files and storing them in Mysql database.
But I get the error while reading in very first json. For reading json I'm using tExtractJSONFileds component.
I'm sure about the configuation set up in talend etl tool its right. I believe there is some problem in json file.
While extracting the component shows error like this
Exception in component tExtractJSONFields_1
javax.xml.stream.XMLStreamException: java.io.IOException: Unexpected symbol: COMMA
at de.odysseus.staxon.base.AbstractXMLStreamReader.initialize(AbstractXMLStreamReader.java:218)
at de.odysseus.staxon.json.JsonXMLStreamReader.<init>(JsonXMLStreamReader.java:65)
at de.odysseus.staxon.json.JsonXMLInputFactory.createXMLStreamReader(JsonXMLInputFactory.java:148)
at de.odysseus.staxon.json.JsonXMLInputFactory.createXMLStreamReader(JsonXMLInputFactory.java:44)
at de.odysseus.staxon.base.AbstractXMLInputFactory.createXMLEventReader(AbstractXMLInputFactory.java:118)
I dont know how to deal with JSONs, So Acc to this error can anyone help me where could be the error in JSON file ?
Is there any value passed as NULL or something else ?
Sample JSON
[
[, {
"tstamp": "123456",
"event": "tgegfght",
"is_duplicate": false,
"farm": "dyhetygdht",
"uid": "tutyvbrtyvtrvy",
"clientip": "52351365136",
"device_os_label": "MICROSOFT_WINDOWS_7",
"device_browser_label": "MOZILLA_FIREFOX",
"geo_country_code": "MA",
"geo_region_code": "55",
"geo_city_name_normalized": "agadir",
"referer": "www.abc.com",
"txn": "etvevv5r",
"txn_isnew": true,
"publisher_id": 126,
"adspot_id": 11179502,
"ad_spot": 5188,
"format_id": 1611,
"misc": {
"PUBLISHER_FOLDER": "retvrect",
"NO_PROMO": "rctrctrc",
"SECTION": "evtrevr",
"U_COMMON_ALLOW": "0",
"U_Auth": "0"
},
"handler": "uint"
}, , ]
Thanks in advance !!
You have extra empty commas in your sample json.
Your Sample Json should look like
[{
"tstamp": "123456",
"event": "tgegfght",
"is_duplicate": false,
"farm": "dyhetygdht",
"uid": "tutyvbrtyvtrvy",
"clientip": "52351365136",
"device_os_label": "MICROSOFT_WINDOWS_7",
"device_browser_label": "MOZILLA_FIREFOX",
"geo_country_code": "MA",
"geo_region_code": "55",
"geo_city_name_normalized": "agadir",
"referer": "www.abc.com",
"txn": "etvevv5r",
"txn_isnew": true,
"publisher_id": 126,
"adspot_id": 11179502,
"ad_spot": 5188,
"format_id": 1611,
"misc": {
"PUBLISHER_FOLDER": "retvrect",
"NO_PROMO": "rctrctrc",
"SECTION": "evtrevr",
"U_COMMON_ALLOW": "0",
"U_Auth": "0"
},
"handler": "uint"
}]
OR
[
{
"somethinghere": "its value"
},
"somethingelse": "its value"
]
Your sample json is not valid json, due to the spurious extra commas on the second and last lines. Json only allows commas BETWEEN elements of a vector or object, and empty elements are not allowed.
how can I send JSON data to apigility using an HTTP POST? I'm trying to send this data:
{
"nombre_pais": "MEXICO",
"id": "20",
"artist": "JUAN AGUIRRES",
"title": "CRAZY",
"genero": "Balada, Pop",
"ocupacion": "Cantante, Productos",
"sitio_web": "www.juanAGUIRRE.com",
}
but I get an error:
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Bad Request",
"status": 400,
"detail": "JSON decoding error: Syntax error, malformed JSON"
}
What should I do? Thank you.
I guess when someone tells you "JSON decoding error: Syntax error, malformed JSON" you should check the syntax of your JSON. http://jsonlint.com/ is one of many online validators. You will find that you have an extra trailing comma after the last value.
Every common language now has the ability to automatically create JSON, don't try doing it yourself.
{
"jsonStringData": " ["Coil",{"CHARGE_ID":"T862270","PROD_ID":"S878412","COMBINE_SPLIT_IND":"S",
"WEIGHT":"234244","FEET":"3535","ORDER_NUMBER":"LI91004","OIL_DRY_IND":"D",
"NEXT_FACILITY":"WHSE", "DEFECT_CODE":"","TEST_CUT_IND":"","NSTD_FAC_REASON_CODE":"",
"COMMENTS":"","SCRAP_FEET":""}]"
}
When I parsed above JSONString using "http://jsonlint.com/", it gives me below error message. I am not sure what that error mean.
Please help me to get the right JSONString.
Error :
Parse error on line 2:
...sonStringData": " ["Coil",{"CHARGE_ID":"
-----------------------^
Expecting '}', ':', ',', ']'
Remove the " after the : and also the closing one at the end.
{
"jsonStringData": [
"Coil",
{
"CHARGE_ID": "T862270",
"PROD_ID": "S878412",
"COMBINE_SPLIT_IND": "S",
"WEIGHT": "234244",
"FEET": "3535",
"ORDER_NUMBER": "LI91004",
"OIL_DRY_IND": "D",
"NEXT_FACILITY": "WHSE",
"DEFECT_CODE": "",
"TEST_CUT_IND": "",
"NSTD_FAC_REASON_CODE": "",
"COMMENTS": "",
"SCRAP_FEET": ""
}
]
}
The quote just before Coil ends the string which was a value. Just after this string you should have either } or , :
(from json.org)
But it looks like the error was to put a json encoded array into quotes when building the complete object.
You should probably have
"jsonStringData": ["C...
instead of
"jsonStringData": " ["C...