Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
JSON libraries handling special chars
Hi,
We have a customer with the name "Univé Noord-Holland"
We send this customer with an API to an external system.
When we retrieve this customer we can get the customers name:
{
"id": 5234,
"name": "Naam",
"value": "Univ\u00e9 Noord-Holland"
}
the "é" is escaped in the json.
When we use RTI_JSON or SRP_JSONX_GET to decode "value" we get (correct) "Univé Noord-Holland" after we UTF8_ANSI the string because our OI is set to ANSI.
But when we use srp_json we get "UnivຠNoord-Holland" (raw)
converting it with UTF8_ANSI we get "Univ? Noord-Holland"
Can we get this right using SRP_JSON?
Regards Ed
We have a customer with the name "Univé Noord-Holland"
We send this customer with an API to an external system.
When we retrieve this customer we can get the customers name:
{
"id": 5234,
"name": "Naam",
"value": "Univ\u00e9 Noord-Holland"
}
the "é" is escaped in the json.
When we use RTI_JSON or SRP_JSONX_GET to decode "value" we get (correct) "Univé Noord-Holland" after we UTF8_ANSI the string because our OI is set to ANSI.
But when we use srp_json we get "UnivຠNoord-Holland" (raw)
converting it with UTF8_ANSI we get "Univ? Noord-Holland"
Can we get this right using SRP_JSON?
Regards Ed
Comments
Compile Function Test(VOID) $insert SRPJSONX Declare function SRP_Json, UTF8_ANSI Declare subroutine SRP_Json Json = '{' Json := '"id": 5234,' Json := '"name": "Naam",' Json := '"value": "Univ\u00e9 Noord-Holland"' Json := '}' SRP_Jsonx_Parse("Test", Json) Test1 = SRP_Jsonx_Get("value") SRP_Jsonx_End() Test1 = UTF8_ANSI(Test1) Handle = 0 If SRP_Json(Handle, "Parse", Json) EQ "" then Test2 = SRP_Json(Handle, "GetValue", "value") SRP_Json(Handle, "Release") end Test2 = UTF8_ANSI(Test2) Ans = Test1 EQ Test2 Return Ans
Thanks for now..
Ed
In the version history after 2.2 we only read that "Validate" was added to srp_json.
Thanks again for the help.
After installing the latest utlities....
In an openengine service we have SRP issues..
SRP_ENCODE break on line 67
SRP_DECODE break on 62
SRP_MATH break on line 89
Are there dependencies?
It looks like it's solved now....
I am sure the openengine service was restarted. Maybe I only restarted the dev-engine. After a re-restart it looks like everything is woking now.