Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

This is my main JSON file

{
  "chartType" : ["column", "column", "pie"],
  "chartTitle": ["Cantidad de equipos", "Cantidad de artículos consumibles","Cantidad de empleados a cargo"],
  "yAxisTitle": ["Equipos", "Consumibles", "Empleados"],
  "seriesName": ["conexion_equipos_basededatos_json.php", "conexion_consumibles_basededatos_json.php", "conexion_basededatos_json.php"],
  "seriesData": ["conexion_equipos_basededatos_json.php", "conexion_consumibles_basededatos_json.php", "conexion_basededatos_json.php"]
}

That loads others PHP JSON_ENCODE files in "seriesName" and "seriesData".

These JSON results generate keys "id" and "nombre" (spanish word for name).

How read values for these keys through Angular Service $http.get of the main JSON?

**UPDATE (06/03/2016)**

I'm middle of road!

I read the JSON objects from "seriesName" array with angular.fromJson function as follow:

var deserialize = angular.FromJson(data);

var objects = deserialize.seriesName;

console.log(objects);

That's throws me an array of objects:

 ["conexion_equipos_basededatos_json.php", "conexion_consumibles_basededatos_json.php", "conexion_basededatos_json.php"]

Thus, how I could read the objects contained in these URL's through Angular?

share|improve this question

First of all you need to decode the JSON in PHP using json_decode(), then you treat the result as an object.

Try something like;

$data = xyz; // pass in the JSON object
$res = json_decode($data); // decode JSON
$chartType = $res->chartType; // access property as an object

You can also try var_dump($res) to get a clearer understanding of the structure and how to access it;

share|improve this answer
    
It is useful in PHP, but my question is related to Angular.JS... What would the aproximated function of json_decode for Angular? – Ulises Vargas De Sousa Jun 3 '16 at 14:15
    
Sorry I misread your question – Ally Jun 3 '16 at 14:21

You can do following.

$http.get('url_to_json').then(fucntion(response) {
  var myJson = response.data;
  var keys = Object.keys(myJson);
    console.log('Your keys', keys);
}, fucntion(error) {

});
share|improve this answer
up vote 0 down vote accepted

Altough have button, I could resolve this issue.

I have created a repository that integrates Angular.js, PHP, and Highcharts, with Materialize.css, adding series dynamically from external JSON.

link: https://github.com/Nullises/DynamicSeriesHighchartsAngular

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.