0

This is the first time i am working with Web sockets please pardon any error.

I am using rxjs websockets with Angular. the data i get in the browser is something like this from the websocket

'[["lnkd",76.86839599398574],["mu",127.8241808237684],["msft",174.50062080196034],["yhoo",96.43342811472303]]'

This is data i get in console . I am not able to use ngFor on this as it is a String type data . I want to be able to get the data in form of an array or array instead of in String is this possible .

As of now i get this in broswer using {{data | async }} but i need it a table format using ngfor

1 Answer 1

1

This is a JSON string. You need to first parse it into a object using JSON.parse() as described here.

https://www.w3schools.com/js/js_json_parse.asp

var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
Sign up to request clarification or add additional context in comments.

2 Comments

is it a json it starts with [ instead of {
you have a 2 dimensional array formatted as a JSON string. Top Level Arrays are legal in JSON objects. stackoverflow.com/questions/3833299/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.