Answers for "access json children java"

PHP
1

php access json object

<?php
  // JSON string
  $someJSON = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';

  // Convert JSON string to Object
  $someObject = json_decode($someJSON);
  echo $someObject[0]->name; // Access Object data
?>
Posted by: Guest on April-15-2020
0

how to access array datat in class component react

import React, { Component } from 'react'
import './TourList.scss';
import Tour  from '../Tour/Tour';
import { tourData } from './tourData'; //impoert array of data
export default class TourList extends Component {
    state={
        tours:tourData // store array of data in state
    }
    render() {
        const {tours}=this.state // store  state in variable
        

        return (
            <section className="toulist">
            {tours.map(tour=>{ // using map method to destructure
                return <Tour key={tour.id} tour={tour} />; //pass as props
            })}
            
            </section>
        )
    }
}
//----------------------------------------------------
 //how to access props in class component
   const {id,city}=this.props.tour//props
Posted by: Guest on May-19-2020

Browse Popular Code Answers by Language