Saurabh Sinha
Saurabh Sinha

Reputation: 1800

parse a string to extract specified content in java

I need to extract NSID from a list of string which is stored in a file.the string look like this. the string inside jsonFlickrApi() is in json format.

[email protected]|jsonFlickrApi({"user":{"id":"21849273@N06", "nsid":"21849273@N06", "username":{"_content":"eire5555"}}, "stat":"ok"})

If I want to parse this and get the nsid, in java what approach i should take. Should I write a parser or is there any library available to parse this json inside jsonFlickrAPI()

Upvotes: 0

Views: 42

Answers (1)

Juned Ahsan
Juned Ahsan

Reputation: 68715

The string is a mix of a json and some other text. You may try to split the json part and then can use a json parser to retrieve nsid easily.There are various java json parsers available such as GSON.

Upvotes: 1

Related Questions