We have to parse a json structure similar to below.
project {
header {
}
pool {
}
cmp {
name = "";
id = "";
desc = "";
cmp [
{
name = "";
id = "";
desc = "";
}
{
name = "";
id = "";
desc = "";
}
{
name = "";
id = "";
desc = "";
cmp [
{
name = "";
id = "";
desc = "";
}
}
}
}
The issue is, cmp element is present in the json infinitly (and it is recursive too).
The cmp element contains lots of properties other than name, id and desc. But we need only name, id and desc to extract from the jSON.
I can able to parse the JSON string using com.json.parsers.JSONParser. But populating the parsed JSON to a model class/bean class is not working. It may be a simple logic. But I cannot. Please help...
The json file is generated as an output of one modeling software.
I want to parse this, using java. Can somebody help me to parse this?
Hope I have explained the issue correctly. Your help will be helpful for us.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…