I'm working with some 3rd-party APIs that return JSON data. When I call them directly from my VCL app, everything is fine. I put them into my XData service, and when I call them from VCL, I get back JSON data and can parse it with different parsers and that's fine. In fact, I created a class for each of these; I pass the JSON string to a factory method and it gives me back a class instance (usually a TList<something>
) that contains the data I received.
However, when I call the XData services from my WebCore client and get back the TXDataClientResponse
, I get the same JSON data, but I can't figure out how to parse it. The data is returned as
{ "value": {... JSON from 3rd-party site ...} }
I can get this 3rd-party JSON data as a string on the WEB Core client, but how do I work with it?
TXDataClientResponse.ResultAsObject
and ResultAsArray
return a TObject, but it's a JSON string.
TXDataClientResponse.Result
is a Variant.
I can't use System.JSON
or REST.JSON
or superobject
or any other JSON units in WEB Core.
I can't use the classes I created that work in VCL for the same reason: they use a JSON parser that won't compile in WEB Core.
Here's an example that I get as the "value":
{ "success": true, "data": { "voices_list": [ { "Engine": "neural", "VoiceId": "Jo", "VoiceGender": "Female", "VoiceWebname": "Jo", "Country": "US", "Language": "en-US", "LanguageName": "English, US" }, { "Engine": "neural", "VoiceId": "Ken", "VoiceGender": "Male", "VoiceWebname": "Ken", "Country": "US", "Language": "en-US", "LanguageName": "English, US" } ] } }
That's what I get from calling the XData service, both VCL and WEB Core. I can parse it in the VCL client, but I don't know what to do with it in the WEB Core client.
Maybe this is something I need to handle on the XData side? If so, how?
I've searched through the docs and can't find anything that relates to this in either the XData docs or the WEB Core docs.