#1 2017-01-19 22:21:46

fakie
Banned
Registered: 2016-10-28
Posts: 36

Reading a complete JSON file into an object?

Is it possible with appbuilder to read a complete JSON file into an object?
Like we do with php.

<?php
$json_file = file_get_contents('assets/data/clubs.json');
// convert the string to a json object
$arr = json_decode($json_file);
$title = $arr->result->title;
?>

The exanples of data.json in the report samples all start with a block quote, and not a curly bracket, and we use it by saying something like Record.ID, but usually a json file would start with a curly bracket.
Or am I wrong?

ps. I think the mapping of fields from the json url to the report control is fantastic. But we would have finer control over our app if we could read the json into various objects, and assign these various objects to report controls.

ie. json example

  {
		"title": "Whatever Heading",
		"logo": "lfh.jpg",
		"groups": [{
			"groupname": "Clar Carrot",
			"acronym": "CC",
			"logo": "CC.png",
			"contactnumber": "123",
			"email": "hallo@cc.com"}],
        "data" : [{	"ID":1,
					"Title":"Lorem ipsum",
					"Group":"CC",
					"ImageUrl":"app/images/sample.png",
					"Description":"Lorem ..end."
				},{
					"ID":2,
					"Group":"CC",
					"Title":"Lorem 2m",
					"ImageUrl":"app/images/sample2.png",
					"Description":"Lorem ..exit."
				}
  }

This is my favourite quote.

Offline

#2 2017-01-19 22:51:20

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: Reading a complete JSON file into an object?

Hello fakie,

Take a look at the various "JSON*" samples. Certainly we can deal with JSON objects loading from files and server's responses. Please let me know if you have any further question after take a look at the refered samples.

P.S. Maybe you can find another useful samples searching by "json" in the App Builder's samples dialog.

Online

#3 2017-01-19 23:51:53

fakie
Banned
Registered: 2016-10-28
Posts: 36

Re: Reading a complete JSON file into an object?

Will do.


This is my favourite quote.

Offline

#4 2017-01-19 23:54:41

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: Reading a complete JSON file into an object?

Hello fakie,

fakie wrote:

Will do.

Just remember JSON objects are like any other Javascript object, and that App Builder provides the appropiate actions to deal with Javascript objects, and, App Builder also provide dozens of actions to deal with Arrays, which is another common "source" in JSON objects.

Online

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.