How do you process the data received from API in ND-JSON format?

How to process the data received from API in ND-JSON format?

Strip the returned content of any \n or \r\n characters using text replacement blocks, and replace with a comma. You may also need to add square brackets [ ] around the outside of your json.

ndjson

1 Like

when I do so I receive the output <!DOCTYPE

That's usually an error message.
Show your response content before you try to process it.

1 Like

The response content is from ND-JSON streaming. Could be that the problem is because I am trying to display the response in Label1.Text?

Can you provide an example of the response you get ?

My blocks:

Here is the response I get in the app:

Here is the response I receive in the terminal:

Just set the responseContent to your label, no processing

Is your token correct? Or you use xxxxxx as token in your blocks just for security?

You most probably got an eror message in html format... therefore

Also do not initialize a global variable with some text from a textbox

Use Textbox1.Text directly in the url instead of that global variable

Taifun

Your terminal response is just JSON.
No \n

1 Like

If you want a chess board from buttons.

It is just for security

Are you going to show your raw responseContent, which will contain the error message ?

Now there is not response at all:

is there a space after Bearer?
in case both the token and game id are correct, these blocks should work...
Taifun

There is a space between Bearer and the token. The token is correct.
I must to remark that I can receive correct response (JSON response) for another requests from the API. The problem is with ND-JSON response (streaming data)

The response is definitely ND-JSON format. In the uploaded picture of the terminal I show only begining of the streaming response.

try logcat to find out what is going on

Taifun


ndjson test

I received a list of JSON objects, joined by \n separators.

Splitting at \n gave me a list of JSON objects that look ready for the web block that decodes JSON as dictionaries.

2 Likes