I need to get elementId
from my JSON file which is shown below:
{
"intents": [{
"type": "PathIntent",
"id": "0x0",
"appId": "org.onosproject.cli",
"resources": ["DefaultLink{src=ConnectPoint{elementId=00:00:00:00:00:01/-1, portNumber=0}, dst=ConnectPoint{elementId=of:0000000000000003, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}", "DefaultLink{src=ConnectPoint{elementId=of:0000000000000003, portNumber=3}, dst=ConnectPoint{elementId=of:0000000000000002, portNumber=1}, type=DIRECT, state=ACTIVE, durable=false}", "DefaultLink{src=ConnectPoint{elementId=of:0000000000000002, portNumber=2}, dst=ConnectPoint{elementId=of:0000000000000004, portNumber=3}, type=DIRECT, state=ACTIVE, durable=false}", "DefaultLink{src=ConnectPoint{elementId=of:0000000000000004, portNumber=2}, dst=ConnectPoint{elementId=00:00:00:00:00:04/-1, portNumber=0}, type=EDGE, state=ACTIVE, durable=false}"],
"state": "INSTALLED"
}]
}
To get an JSON-Array is very easy:
JSONObject obj = new JSONObject("...");
JSONArray arr = obj.getJSONArray("resources");
You will get an array of this elements
"DefaultLink{src=ConnectPoint{elementId=00:00:00:00:00:01/-1, portNumber=0}, dst=ConnectPoint{elementId=of:0000000000000003, portNumber=1}, type=EDGE, state=ACTIVE, durable=false}"
Unfortunately you need to parse the String i guess.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.