2

an array of server:

Array ( [28.01.2015] => Array ( [03] => 2 [02] => 4 ) )

was converted into a string using the json_encode.

The result was a string:

{"28.01.2015":{"03":2,"02":4}}

How to use Javascript to convert this string into an array ?

Brad
  • 159,648
  • 54
  • 349
  • 530
andrei
  • 23
  • 4

3 Answers3

1
JSON.parse('{"28.01.2015":{"03":2,"02":4}}');

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

Brad
  • 159,648
  • 54
  • 349
  • 530
1

You can turn that into a JavaScript object by using JSON.parse():

var my_object = JSON.parse('{"28.01.2015":{"03":2,"02":4}}');
Brennan
  • 5,632
  • 2
  • 17
  • 24
1

For achieve this, you need use JSON.parse.

JSON.parse('{"28.01.2015":{"03":2,"02":4}}');

Or you could organize better:

var string = '{"28.01.2015":{"03":2,"02":4}}';
var object = JSON.parse(string);