Message from JavaScript discussions

March 2019

— If that's what you mean

— 

Hello, i have a beginner question. I fetch data from an API where i get a lot of lines like this. I want to get the string which comes after "address" (public key) and the number after "stake". My first way would be to split everything at the comma, get rid of the quotation marks and so on and work from that. Is there a better way like regex or how would a professional do it?

— JSON.parse(data).address

— This data is JSON

— JSON parsers turn that string into objects

— They exist for pretty much every language

— Ah damn, thanks :D

— This is for JavaScript

— Source:

JSON.parse('{"foo":"bar"}').foo


Result:
'bar'

— JSON parsers are built into JS and PHP

— And probably others

— If not, there are libraries