Carbon_Fields\Field\Group_Field::to_json PHP Method

to_json() public method

This data will be available in the Underscore template and the Backbone Model.
public to_json ( boolean $load ) : array
$load boolean Should the value be loaded from the database or use the value from the current instance.
return array
    public function to_json($load)
    {
        $fields_data = array();
        foreach ($this->get_fields() as $field) {
            // The field default value should be set manually if the field is not loaded
            if (!$load) {
                if ($field->get_value() === null) {
                    $field->set_value($field->get_default_value());
                }
            }
            $fields_data[] = $field->to_json($load);
        }
        $group_data = array('group_id' => $this->get_group_id(), 'name' => $this->get_name(), 'label' => $this->get_label(), 'fields' => $fields_data);
        return $group_data;
    }