Unable to parse a valid Json from Arabic text - json

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'

Related

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}]}]",

Invalid JSON - Cannot see why

The following JSON string comes back as invalid in several formatter tests. I cannot figure out for the life of me what is wrong!
{
"draw": 122,
"recordsTotal": 1496,
"recordsFiltered": 1496,
"data": [["11315","1403","John Doe","Parking Pass","-","Hyundai Sonata - Grey ABC 123 ","09-01-2016 2:00 AM","09-01-2016 7:00 AM","-"]]
}
https://jsonformatter.org/ is saying:
Parse error on line 5: ...,"Parking Pass","-","Hyundai Sonata - Gr
-----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
https://jsonformatter.curiousconcept.com/ says:
Error:Invalid characters found.[Code 18, Structure 28]
and highlights the line "Hyundai Sonata - Grey ABC 123 ",
What the heck am I missing? I dont see any invalid characters anywhere. If I paste it into Notepad++ its not showing anything but "CRLF" on the line breaks.
After checking, it turns out that the value, which was being returned from a database, had a tab in it. I created a function to strip out any non ASCII chars and its working fine now

Escape a hypen in JSON response from Mule

I am using Anypoint Studio 6.1 and Mule 3.8.1 and have the following JSON response from a Mule workflow:
{
"Description": "Top 10 games:
- Mario Kart
- Legend of Zelda"
}
This fails validation with the following error:
Error: Parse error on line 2:
{ "Description": "Top 10 games: - M
-----------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
I have tried escaping the special characters put it still does not work. How can I change the response to pass JSON v4 validation. The JSON validator I have been using is http://jsonlint.com/
Thanks
The root cause of the issue is carriage return in the JSON response. The valid JSON should be as below
{
"Description": "Top 10 games:\r\n- Mario Kart\r\n- Legend of Zelda"
}
Please provide more details on where you are receiving this description. is it from XML or any other source. Also it will be helpful if you post your DWL code as well.

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

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 .

After parsing a value an unexpected character was encountered: ". Path '[0] Issue

I've been taking an error while deserialize json from file path.
My json model that comes from Model is (Model.GroupsJson) so:
[{\"GroupContent\":\"<p><img alt=\"\" src=\"http://localhost:56502/images/uploads/1471441332_flat-style-circle-add.png\" style=\"height:32px; width:32px\" /></p>\n\",\"Questions\":[{\"QuestionId\":\"57c3de87b6455e070800df0d\",\"Order\":\"0\"},{\"QuestionId\":\"57c91f85b6455e13b0646e7d\",\"Order\":\"0\"},{\"QuestionId\":\"57c8317ab6455e08b47ad839\",\"Order\":\"0\"}]},{\"GroupContent\":\"<p>aaaa</p>\n\",\"Questions\":[{\"QuestionId\":\"57c7d4bfb6455e1a08f17a3a\",\"Order\":\"1\"},{\"QuestionId\":\"57c3d753b6455e1840ccf8b5\",\"Order\":\"1\"}]}]
and after i try to deserialize json model :
List<GroupModel> groupList = JsonConvert.DeserializeObject<List<GroupModel>>(model.GroupsJSON)
And then this exception throws:
Additional information: After parsing a value an unexpected character was encountered: ". Path '[0].GroupContent', line 1, position 31.
What do I have to do? Should I encode backslash characters on model?