How to remove data from JSON into a new group

Source: Internet
Author: User
How to take data out of JSON and put it in a new group
The JSON data is as follows:
{
"Communitymodel": [
{
"UUID": "Xxxxxx-xxxxxx-xxxxxxx-xxxxxx1",
"CommunityName": "Green Garden",
"Communityaddress": "XXXX203 number",
"Longitude": "12.33333333",
"Latitude": "143.1121222",
"Form": "Commercial housing",
"Buildingnum": "100",
"Ownernum": "1800",
"Carportnum": "1800"
},
{
"UUID": "Xxxxxx-xxxxxx-xxxxxxx-xxxxxx2",
"CommunityName": "Green Garden 2",
"Communityaddress": "No. No. 203 XX Road",
"Longitude": "12.33333333",
"Latitude": "143.1121222",
"Form": "Commercial housing",
"Buildingnum": "100",
"Ownernum": "1800",
"Carportnum": "1800"
}
]
}

Obtained by PHP, requires that the UUID and communityname in the JSON be returned in a new array $arr.

My code is as follows:

$url _get = ' http://api.com:90/1.php ';
$json =json_decode ($this->curlget ($url _get));
foreach ($json as $jsonvalue)
{
。。。。 How to write here
Dump ($jsonvalue);
}

------Solution--------------------
It's weird, actually, the key name is blank at both ends.
$s =<<< JSON
{
"Communitymodel": [
{
"UUID": "Xxxxxx-xxxxxx-xxxxxxx-xxxxxx1",
"CommunityName": "Green Garden",
"Communityaddress": "XXXX203 number",
"Longitude": "12.33333333",
"Latitude": "143.1121222",
"Form": "Commercial housing",
"Buildingnum": "100",
"Ownernum": "1800",
"Carportnum": "1800"
},
{
"UUID": "Xxxxxx-xxxxxx-xxxxxxx-xxxxxx2",
"CommunityName": "Green Garden 2",
"Communityaddress": "No. No. 203 XX Road",
"Longitude": "12.33333333",
"Latitude": "143.1121222",
"Form": "Commercial housing",
"Buildingnum": "100",
"Ownernum": "1800",
"Carportnum": "1800"
}
]
}
JSON;
$a = Json_decode ($s, 1);
foreach ($a [' Communitymodel '] as $v) {
$arr [] = Array (' uuid ' = = $v [' uuid '], ' communityname ' = ' + ' $v [' communityname ']);
}
Print_r ($arr);
Array
(
[0] = = Array
(
[UUID] = xxxxxx-xxxxxx-xxxxxxx-xxxxxx1
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.