Cant validate JSON when using different language. Error invalid characters found - json

First time im trying to create a JSON file,
Im trying to create a JSON file with different language other than English , but when i try to validate, it show Error Invalid characters found.
i tried this
{
"data": [
{
"id": "1",
"title": "Oru Velli Thaaram Vaana Veedhiyil",
"lyrics": "ഒരു വെള്ളിത്താരം വനവീഥിയിൽ തെളിയവേ
കുളിരീറൻ കാറ്റും കുഞ്ഞുതരാട്ട് മൂളവേ
ഇരുളിനലകൾ മൂടും ധരയിതിലൊരു ദീപം
കദനഭാരമെല്ലാം നീക്കിടുന്ന സ്നേഹം
പിറന്നു മണ്ണിലുഷസ്സിൻ ശോഭ പോലെ
(ഒരു വെള്ളിത്താരം…
മരുഭൂവിൽ അലയുമ്പോൾ ആ താരം മുൻപേ
മറയാതെ രാജക്കൾക്കതുമാർഗമായി
മരുഭൂവിൽ അലയുമ്പോൾ ആ താരം മുൻപേ
മറയാതെ രാജക്കൾക്കതുമാർഗമായി
പുൽക്കൂടും തേടിത്തേടി ബെത്ലഹേമിലവരണയുമ്പോൾ
ഗീതങ്ങൾ പാടിപ്പാടി വാനദൂതരും അണയുന്നൂ
തിരുസുതനെ കാണുംനേരം പാടുന്നു ഗ്ലോറിയ …
(ഒരു വെള്ളിത്താരം…
ശാരോനിൻ താഴ്വാരം തഴുകുന്ന കാറ്റെ
വരുമോ എൻ നാഥൻറെ അരികിൽ നീ മെല്ലെ
ശാരോനിൻ താഴ്വാരം തഴുകുന്ന കാറ്റെ
വരുമോ എൻ നാഥൻറെ അരികിൽ നീ മെല്ലെ
തഴുകൂ നിൻ വിരലാൽ നെറുകിൽ സ്നേഹനാഥനെ ആലോലം
പാടൂ നൽ ശ്രുതിയാൽ കാതിൽ സാന്ദ്രമാനന്ദ സംഗീതം
ഈ രാവിൽ പാരാകെ പാടുന്നു ഗ്ലോറിയ
(ഒരു വെള്ളിത്താരം…",
},
{
"id": "2",
"title": "Pukootil Vannu Jaathanayi",
"lyrics": "പുൽക്കൂട്ടിൽ വന്നു ജാതനായി
നക്ഷത്രം ഇന്ന് മിന്നി നിന്നു
ക്രിസ്മസ് രാവിൻറെ ഗാനമായി
വിണ്ണിൽ ആനന്ദമേളമായി താരകം ദീപമായ്
കൺകളിൽ തിളങ്ങി നിന്നു (2 )
ദൂതരാ വീണകൾ മീട്ടിടുന്നിതാ
ലോകരാ കീർത്തനം കേട്ടിടുന്നിതാ
ദേവദാരു പൂത്തു പാതിരാവു പെയ്തു
മഞ്ഞുതുള്ളി വീണവീഥി മിന്നിടുന്നു
( പുൽക്കൂട്ടിൽ)
വിദ്വരോ കാഴ്ചകൾ നല്കിടുന്നിതാ
വിന്നതിൽ നോക്കി സംപ്രീതരായിതാ
കീറ്റുശീല തന്നിൽ ദിവ്യശോഭ കണ്ടു
ആട്ടിടയരെത്തി ആർത്തു പാടിടുന്നു
( പുൽക്കൂട്ടിൽ)",
}
]
}
Error shows as INVALID JSON , Invalid characters found.
please help me to resolve this problem .

Problem Coming from
"lyrics": "ഒരു വെള്ളിത്താരം വനവീഥിയിൽ തെളിയവേ
Error Type
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
Reason
Line breaks inside your string . Encode with \n .A string is a sequence of zero or more Unicode characters .

Related

How to get object name when it contains DOTs, CURLY BRACES and HASHTAGs on JSONPath?

I have the following JSON structure, generated by Zabbix Discovery key, with the following data:
[{
"{#SERVICE.NAME}": ".WindowsService1",
"{#SERVICE.DISPLAYNAME}": ".WindowsService1 - Testing",
"{#SERVICE.DESCRIPTION}": "Application Test 1 - Master",
"{#SERVICE.STATE}": 0,
"{#SERVICE.STATENAME}": "running",
"{#SERVICE.PATH}": "E:\\App\\Test\\bin\\testingApp.exe",
"{#SERVICE.USER}": "LocalSystem",
"{#SERVICE.STARTUPTRIGGER}": 0,
"{#SERVICE.STARTUP}": 1,
"{#SERVICE.STARTUPNAME}": "automatic delayed"
},
{
"{#SERVICE.NAME}": ".WindowsService2",
"{#SERVICE.DISPLAYNAME}": ".WindowsService2 - Testing",
"{#SERVICE.DESCRIPTION}": "Application Test 2 - Slave",
"{#SERVICE.STATE}": 0,
"{#SERVICE.STATENAME}": "running",
"{#SERVICE.PATH}": "E:\\App\\Test\\bin\\testingApp.exe",
"{#SERVICE.USER}": "LocalSystem",
"{#SERVICE.STARTUPTRIGGER}": 0,
"{#SERVICE.STARTUP}": 1,
"{#SERVICE.STARTUPNAME}": "automatic delayed"
}]
So, what i want to do is: Use JSONPath to get ONLY the object that {#SERVICE.NAME} == WindowsService1...
The problem is, i am trying to create the JSONPath but it's giving me a couple of errors.
Here's what i tried, and what i discovered so far:
JSONPath:
$.[?(#.{#SERVICE.NAME} == '.WindowsService1')]
Error output:
jsonPath: Unexpected token '{': _$_v.{#SERVICE.NAME} ==
'.WindowsService1'
I also tried doing the following JSONPath, to match Regular Expression:
$.[?(#.{#SERVICE.NAME} =~ '^(.WindowsService1$)')]
It gave me the same error - So the problem is not after the == or =~ ...
What i discovered is, if i REMOVE the curly braces {}, the hashtag # and replace the dot . in "Service name" with _ (Underline), in JSONPath and in JSON data, it works, like this:
Data without # {} . :
[{
"SERVICE_NAME": ".WindowsService1",
[...]
JSONPath following new data structure:
$.[?(#.SERVICE_NAME == '.WindowsService1')]
But the real problem is, i need to maintain the original strucutre, with the curly braces, dots, and hashtags...
How can i escape those and stop seeing this error?
Thank you...
$.[?(#['{#SERVICE.NAME}'] == '.WindowsService1')]

JSON Data is Not Valid

I am getting "JSON Data is Not Valid" error on this Json and i couldn't find what is wrong with it.When I put it in something like a JSON Validator it says
Error: Parse error on line 66: ... "InfoStr": "[{" BankEftCode
":" 00
----------------------^ Expecting 'EOF', '}', ':', ',', ']', got 'undefined'
PS: I put 1234s and aaaa's on names and numbers for privacy so don't worry about them.
{"Header":{
"CallerId":"0060030000",
"RequestId":"10213",
"Status":"SUCCESS",
"ErrorCode":null,
"ErrorMessage":null
},"Body":{
"ComplaintSource":"aaa",
"BankEftCodeIssuer":"12345",
"BankEftCodeAcquirer":"12345",
"EntryUserName":"aaa",
"BankComplaintNo":"aaa",
"ComplaintTimestamp":"1234",
"CustomerIdType":"aaa",
"CustomerIdValue":"1234",
"CustomerName":"aaa",
"CustomerLastName":"1234",
"CustomerCompanyTitle":"",
"IsVIP":false,
"CustomerSegment":"aaa aaa",
"CustomerMobilePhone":"1234",
"CustomerIBAN":"1234567890",
"CustomerAccountNo":"1234",
"CustomerEmail":"",
"ComplaintStatus":"",
"ComplaintStatusStep":"",
"ComplaintStatusDetail":"",
"ComplaintCategory":"C1",
"ComplaintMainTopic":"C1.1",
"ComplaintSubTopic":"C1.1.3",
"ComplaintDate":"2022-05-24T11:28:00+03:00",
"ComplaintExplanation":"aaa",
"ComplaintAmount":8670.0,
"ComplaintCurrency":"TRY",
"ReconciliationAmount":0.0,
"ReconciliationCurrency":"TRY",
"ComplaintCardNo":"1234",
"ComplaintMaskedCardNo":"1224",
"ComplaintEncryptedCardNumber":"aaaa",
"RelatedComplaintNo":"0.0",
"TransactionAmount":8670.0,
"TransactionCurrency":"TRY",
"TransactionTimestamp":"12345676",
"TerminalId":"PT6172",
"TerminalLocation":"aaa",
"TransactionDate":"2022-05-23T11:44:00+03:00",
"TransactionRRNNo":"",
"TransactionAuthorizationNo":"",
"TransactionSTANNo":"",
"TransactionTAMRefNo":"aaaaa",
"TransactionCardNo":"12345",
"TransactionMaskedCardNo":"123456789",
"TransactionCardBrand":"M",
"TransactionCardType":"D",
"TransactionHashCardNo":"wertyuıop",
"TransactionTCKN":"123456789",
"TransactionYKN":"",
"TransactionMobilePhoneNumber":"123456789",
"Comment":"",
"PaymentAgent":"",
"PaymentAgentNo":"",
"PaymentSubscriptionNo":"",
"InfoStr":"[{"BankEftCode":"1234567890","TaskId":"12345","RequestUser":"aaa aaa","ResponseUser":"aaa01","RequestTimestamp":"1234567890","ResponseTimestamp":"134567","RequestComment":"aaaa","ResponseComment":"aaa",
"InfoElements":[{"Key":"AtmCashDifferenceCurrency","Value":null,"Type":null},
{"Key":"AtmCashSurplus","Value":"0","Type":null}
]
}]",
"F_TicketProcessType":"",
"NF_TicketProcessType":"",
"AtmResolveCode":"",
"SLADueDatetime":"2022-05-27T09:49:35.966",
"BankSLADueDatetime":"2022-05-25T12:36:22",
"IsInfoRequested":false,
"IssuerSLASatisfied":true,
"AcquirerSLASatisfied":false,
"ComplaintHashCardNo":null,
"ComplaintCardBrand":null,
"ComplaintCardType":null}}
Thanks for helping.
you InfoStr value is a string, not object , so it is not valid , should be
"InfoStr": "[{\"BankEftCode\":\"1234567890\",\"TaskId\":\"12345\",\"RequestUser\":\"aaa aaa\",\"ResponseUser\":\"aaa01\",\"RequestTimestamp\":\"1234567890\",\"ResponseTimestamp\":\"134567\",\"RequestComment\":\"aaaa\",\"ResponseComment\":\"aaa\",\"InfoElements\":[{\"Key\":\"AtmCashDifferenceCurrency\",\"Value\":null,\"Type\":null},{\"Key\":\"AtmCashSurplus\",\"Value\":\"0\",\"Type\":null}]}]",

Unable to parse a valid Json from Arabic text

This appears to be valid Json but Json parsers throw an exception on address text. Can we not have arabic values as Json values?
{
"deliveryTime":"12:34:00",
"deliveryDate":"07-09-2017",
"paymentType":1,
"deliveryMethod":1,
"address":{
"text":"\"7774 جبل الجزيره، طويق"\, "\الرياض \13791 3836، السعودية\"",
"geo":{
"latitude":24.580577,
"longitude":46.518820
},
"noteToDriver":"Near bank",
"country":"Saudi Arabia"
}
}
https://jsonlint.com/ throws an exception but I couldn't figure out the issue. It has double quotes properly escaped, the entire address value is quoted. I think the problem is due to the right to left nature of the language that resulted in the error.
Error: Parse error on line 7:
...4 جبل الجزيره، طويق"\, "\الرياض \13791
-----------------------^
Expecting 'EOF', '}', ':', ',', ']', got 'undefined'

Json.parse Syntax Error

I've got code.
{
s: "ok",
t: [1386493512, 1386493572, 1386493632, 1386493692],
c: [42.1, 43.4, 44.3, 42.8]
}
Why it return code
SyntaxError: JSON.parse: expected property name or '}' at line 2 column 4 of the JSON data
In javascript the keys are presumed to be strings so keys do not need to be in quotes, however in JSON they do. You should change your code to look like
{
"s": "ok",
"t": [1386493512, 1386493572, 1386493632, 1386493692],
"c": [42.1, 43.4, 44.3, 42.8]
}

Parsing complex json in pig?

I have json file in follwoing format:
{ "_id" : "foo.com", "categories" : [], "h1" : { "bar==" : { "first" : 1281916800, "last" : 1316995200 }, "foo==" : { "first" : 1281916800, "last" : 1316995200 } }, "name2" : [ "foobarl.com", "foobar2.com" ], "rep" : null }
So, how do i parse this json in pig..
also, the categories and rep can have some char in it..and might not be always empty.
I made the following attempt.
a = load 'sample_json.json' using JsonLoader('id:chararray,categories:[chararray], hostt:{ (variable_a: {(first:int,last:int)})}, ns:[chararray],rep:chararray ');
But i get this error:
org.codehaus.jackson.JsonParseException: Unexpected character ('D' (code 68)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: java.io.ByteArrayInputStream#4795b8e9; line: 1, column: 50]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1291)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306)
at org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:1582)
at org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:386)
at org.apache.pig.builtin.JsonLoader.readField(JsonLoader.java:173)
at org.apache.pig.builtin.JsonLoader.getNext(JsonLoader.java:157)
at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigRecordReader.nextKeyValue(PigRecordReader.java:211)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:532)
at org.apache.hadoop.mapreduce.MapContext.nextKeyValue(MapContext.java:67)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:143)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:212)
You can use elephant bird pig jar for parsing json. It can parse all sort of json data.
Here are certain examples for parsing json via elephant bird pig using this jar.
https://github.com/twitter/elephant-bird/tree/master/examples/src/main/pig
It doesn't break even if an expected json tag isn't present.