I want to get hold of the value of DashboardCalc, which lies in the following array:
array(1) {
[0]=>
object(MatrixSubHeadline)#27226 (4) {
["schemaHeadline":"MatrixSubHeadline":private]=>
object(common_db_schemacontent)#28107 (12) {
["viewhelp":"common_db_schemacontent":private]=>
NULL
["unsavedTranslations"]=>
array(0) {
}
["objectLangCode":"common_translation_translateobject":private]=>
string(0) ""
["transUseFallback":"common_translation_translateobject":private]=>
bool(true)
["classData":protected]=>
array(15) {
["SchemaContentID"]=>
string(5) "15611"
["SchemaID"]=>
string(3) "132"
["IndexNo"]=>
string(1) "0"
["PageNo"]=>
string(1) "7"
["ContentType"]=>
string(8) "headline"
["QuestionID"]=>
string(1) "0"
["HeadlineContentID"]=>
string(1) "0"
["ImagePath"]=>
string(0) ""
["ThumbPath"]=>
string(0) ""
["Text"]=>
string(21) "Generelle kommentarer"
["ContentSettings"]=>
string(2) "[]"
["CreatedUserID"]=>
string(2) "15"
["CreatedTime"]=>
string(19) "2021-11-11 12:36:00"
["UpdatedUserID"]=>
string(2) "15"
["UpdatedTime"]=>
string(19) "2021-12-17 15:35:00"
}
["classChanges":protected]=>
array(0) {
}
["tableName":protected]=>
string(13) "schemacontent"
["primaryIDName":protected]=>
string(15) "SchemaContentID"
["cacheEnabled":protected]=>
bool(true)
["accountTable":protected]=>
bool(false)
["extraData":protected]=>
array(0) {
}
["saveError":"common_library_dbbase":private]=>
bool(false)
}
["questionList":"MatrixSubHeadline":private]=>
array(1) {
[0]=>
object(MatrixQuestion)#27225 (4) {
["content":"MatrixQuestion":private]=>
object(common_db_schemacontent)#28106 (12) {
["viewhelp":"common_db_schemacontent":private]=>
NULL
["unsavedTranslations"]=>
array(0) {
}
["objectLangCode":"common_translation_translateobject":private]=>
string(0) ""
["transUseFallback":"common_translation_translateobject":private]=>
bool(true)
["classData":protected]=>
array(15) {
["SchemaContentID"]=>
string(5) "15612"
["SchemaID"]=>
string(3) "132"
["IndexNo"]=>
string(1) "1"
["PageNo"]=>
string(1) "7"
["ContentType"]=>
string(8) "question"
["QuestionID"]=>
string(3) "923"
["HeadlineContentID"]=>
string(5) "15611"
["ImagePath"]=>
string(0) ""
["ThumbPath"]=>
string(0) ""
["Text"]=>
string(0) ""
["ContentSettings"]=>
string(21) "{"criteriaenabled":0}"
["CreatedUserID"]=>
string(2) "15"
["CreatedTime"]=>
string(19) "2021-11-11 12:36:00"
["UpdatedUserID"]=>
string(2) "15"
["UpdatedTime"]=>
string(19) "2021-12-17 15:35:00"
}
["classChanges":protected]=>
array(0) {
}
["tableName":protected]=>
string(13) "schemacontent"
["primaryIDName":protected]=>
string(15) "SchemaContentID"
["cacheEnabled":protected]=>
bool(true)
["accountTable":protected]=>
bool(false)
["extraData":protected]=>
array(0) {
}
["saveError":"common_library_dbbase":private]=>
bool(false)
}
["question":"MatrixQuestion":private]=>
object(common_db_question)#27289 (13) {
["schemaUsage":"common_db_question":private]=>
NULL
["viewHelper":"common_db_question":private]=>
NULL
["unsavedTranslations"]=>
array(0) {
}
["objectLangCode":"common_translation_translateobject":private]=>
string(0) ""
["transUseFallback":"common_translation_translateobject":private]=>
bool(true)
["classData":protected]=>
array(23) {
["QuestionID"]=>
string(3) "923"
["OwnerAccountID"]=>
string(1) "0"
["Question"]=>
string(21) "Generelle kommentarer"
["QuestionType"]=>
string(1) "5"
["Answers"]=>
string(178) "{"answers":null,"groupanswers":[{"count":"1","text":"Ja, jeg vil gerne tilf\u00f8je en generel kommentar","index":"0"}],"questions":["Har du andre kommentarer til din trivsel?"]}"
["SubText"]=>
string(59) "(Skriv dine kommentarer ved at trykke på kommentar-ikonet)"
["AllowOther"]=>
string(1) "0"
["MixAnswers"]=>
string(1) "0"
["MustAnswer"]=>
string(1) "0"
["MinAnswers"]=>
string(1) "0"
["MaxAnswers"]=>
string(1) "0"
["Columns"]=>
string(1) "1"
["OtherText"]=>
string(0) ""
["CreatedUserID"]=>
string(2) "15"
["CreatedTime"]=>
string(19) "2021-11-11 12:36:00"
["UpdatedUserID"]=>
string(2) "15"
["UpdatedTime"]=>
string(19) "2021-11-11 12:44:00"
["DashboardShow"]=>
string(1) "0"
["DashboardCalc"]=>
string(1) "0"
["QuestionTags"]=>
string(1) "0"
["UseComment"]=>
string(1) "1"
["IsPublic"]=>
string(1) "0"
["StdAnswer"]=>
string(1) "0"
}
["classChanges":protected]=>
array(0) {
}
["tableName":protected]=>
string(8) "question"
["primaryIDName":protected]=>
string(10) "QuestionID"
["cacheEnabled":protected]=>
bool(true)
["accountTable":protected]=>
bool(false)
["extraData":protected]=>
array(0) {
}
["saveError":"common_library_dbbase":private]=>
bool(false)
}
["text":"MatrixQuestion":private]=>
string(41) "Har du andre kommentarer til din trivsel?"
["index":"MatrixQuestion":private]=>
int(0)
}
}
["questionMap":"MatrixSubHeadline":private]=>
array(1) {
[15612]=>
array(1) {
[0]=>
int(0)
}
}
["useComments":"MatrixSubHeadline":private]=>
bool(true)
}
}
Please note: the array contains a few objects, which are private. I am not sure whether private objects can be accessed or not, or if the "private" is about the name, or the content.
The data is inherited from a database.
You can access object value by using loop iteration like this:
I am selecting here SchemaContentID, SchemaID and IndexNo.
{% for arrayObj in Objs %}
<ul>
<li>{{ Objs.SchemaContentID}}</li>
<li>{{ Objs.SchemaID}}</li>
<li>{{ Objs.IndexNo}}</li>
</ul>
{% endfor %}
thanks for checking out my question i have the following json data
array(568) {
[0]=>
array(11) {
["ID"]=>
string(6) "000001"
["Portrait"]=>
string(12) "BaseGoku.png"
["Name"]=>
string(42) "[The Saiyan who grew up on Earth] Son Goku"
["Series"]=>
string(11) "Dragon Ball"
["MaxRarity"]=>
string(6) "6 Star"
["Type"]=>
string(4) "Blue"
["Class"]=>
string(4) "Tank"
["Era"]=>
string(4) "1980"
["ReleaseDate"]=>
string(10) "2018-03-28"
["Farmable"]=>
string(1) "0"
["Method"]=>
string(17) "Trade Medal Store"
}
[1]=>
array(11) {
["ID"]=>
string(6) "000003"
["Portrait"]=>
string(8) "Goku.png"
["Name"]=>
string(8) "Son Goku"
["Series"]=>
string(11) "Dragon Ball"
["MaxRarity"]=>
string(6) "6 Star"
["Type"]=>
string(6) "Yellow"
["Class"]=>
string(3) "DPS"
["Era"]=>
string(4) "1980"
["ReleaseDate"]=>
string(10) "2018-03-28"
["Farmable"]=>
string(1) "0"
["Method"]=>
string(14) "Standard Gacha"
} etc
i have been tring to decode this and pull the data using a future
Future<Users> fetchInfo() async {
final response = await http.get(jsonplaceholder);
final jsonresponse = json.decode(response.body);
return Users.fromJson(jsonresponse[8]);
}
but i keep getting the error "Error FormatException: Unexpected character(at character 1) array(568)
not to sure what im doing wrong as i am new to flutter
any help would be appreciated thanks
heres the users model
class Users {
final int userID;
final String name;
final String portrait;
final String series;
Users({this.name, this.userID, this.portrait, this.series});
factory Users.fromJson(Map<String, dynamic> usersjson)=> Users(
name: usersjson["name"],
);
}
First of all are you sure this is the json data you're getting cause it should be like
[
{
"ID": "000001"
"Name": "[The Saiyan who grew up on Earth] Son Goku",
"Portrait": "BaseGoku.png",
"Series": "Dragon Ball",
"MaxRarity": "6 start",
"Type": "Blue",
"Class": "Tank",
"Era": "1980",
"Release Date": "2018-03-28",
"Farmable": "0",
"Method": "Trade Medal Store"
}
]
Flutter expects Map type for json.decode. If it's a public api can you please post it here.
I have an array of dictionaries of type <Int,String> like this:
[14: "2", 17: "5", 6: "5", 12: "Ali", 11: "0", 2: "4", 5: "It it it", 15: "5", 18: "2", 16: "5", 8: "2", 13: "4", 19: "4", 1: "2", 4: "12-09-2017 - 9:52"]
I need to get the keys alone and save them in a string, and the values alone and save them in another string.
The results should look like that:
string key = "12,17,6,12,11,2,5,15,18,16,8,13,19,1,4"
string values = "2,5,5,Ali,0,4,It it ti,5,2,5,2,4,4,2,12-09-2017 - 9:52"
A dictionary has a keys and a values property which return the
keys/values as a (lazy) collection. For the values you just have
to join them:
let dict = [14: "2", 17: "5", 6: "5", 12: "Ali", 11: "0", 2: "4", 5: "It it it", 15: "5", 18: "2", 16: "5", 8: "2", 13: "4", 19: "4", 1: "2", 4: "12-09-2017 - 9:52"]
let values = dict.values.joined(separator: ",")
// Ali,5,2,It it it,5,0,4,5,4,4,2,12-09-2017 - 9:52,5,2,2
The keys are integers and must be converted to strings first:
let keys = dict.keys.map(String.init).joined(separator: ",")
// 12,17,14,5,15,11,13,16,19,2,18,4,6,8,1
The order is unspecified, but the same for keys and values.
Try this, this can be refactored I am sure, this is the first logic that hit me.
let dictionary = [14: "2", 17: "5", 6: "5", 12: "Ali", 11: "0", 2: "4", 5: "It it it", 15: "5", 18: "2", 16: "5", 8: "2", 13: "4", 19: "4", 1: "2", 4: "12-09-2017 - 9:52"]
let arrayKeys = dictionary.map({ $0.key})
print(arrayKeys)
var stringValue: String = ""
for value in arrayKeys {
stringValue.append(value.description)
stringValue.append(",")
}
I'm tying to send the last insert id from express to angularjs in my meanjs application.
When I check the id in server side it's returning properly. But in client side I'm not getting it the same way. For eg: say if the Id is 5527d2ed7ab73f7e412117c9, in angular what I'm getting is this:
Resource {0: "5", 1: "5", 2: "2", 3: "7", 4: "d", 5: "2", 6: "e", 7: "d", 8: "7", 9: "a", 10: "b", 11: "7", 12: "3", 13: "f", 14: "7", 15: "e", 16: "4", 17: "1", 18: "2", 19: "1", 20: "1", 21: "7", 22: "c", 23: "9", $promise: undefined, $resolved: true, $get: function, $save: function, $query: function…}0: "5"1: "5"2: "2"3: "7"4: "d"5: "2"6: "e"7: "d"8: "7"9: "a"10: "b"11: "7"12: "3"13: "f"14: "7"15: "e"16: "4"17: "1"18: "2"19: "1"20: "1"21: "7"22: "c"23: "9"$promise: undefined$resolved: true
My code is
Server code
exports.save(function (err, result) {
if (err) {
return res.send(400, err);
}
console.log(result._id);
res.jsonp(result._id);
});
Client code
$scope.$save(function (response) {
console.log(response)
}, onError);
Try returning an object instead, as result._id is a string and resource is expecting an object.
res.jsonp({id : result._id});
console.log(response.id)
I need to output following array
object(stdClass)#6 (14) { ["subcategories"]=>
array(9) { [0]=> object(stdClass)#31 (13) { ["id"]=> string(2) "10"
["parent_id"]=> string(1) "6" ["name"]=> string(8) "Soup" ["description"]=> string(0) "" ["url"]=> string(4) "supy" ["meta_title"]=> string(8) "Soup" ["meta_keywords"]=> string(8) "Soup" ["meta_description"]=> string(0) "" ["image"]=> string(0) "" ["visible"]=> string(1) "1" ["position"]=> string(1) "7" ["path"]=> array(2) { [0]=> RECURSION [1]=> RECURSION } ["children"]=> array(1) { [0]=> int(10) } } [1]=> object(stdClass)#32 (13) { ["id"]=> string(2) "11" ["parent_id"]=> string(1) "6" ["name"]=> string(12) "Сашими" ["description"]=> string(0) "" ["url"]=> string(7) "sashimi" ["meta_title"]=> string(12) "Сашими" ["meta_keywords"]=> string(12) "Сашими" ["children"]=> array(1) { [0]=> int(10) } } [1]=> object(stdClass)#32 (13) { ["id"]=> string(2) "11" ["parent_id"]=> string(1) "6" ["name"]=> string(12) "Сашими" ["description"]=> string(0) "" ["url"]=> string(7) "sashimi" ["meta_title"]=> string(12) "Сашими" ["meta_keywords"]=> string(12) "Сашими" ["meta_description"]=> string(0) "" ["image"]=> string(0) "" ["visible"]=> string(1) "1" ["position"]=> string(1) "8" ["path"]=> array(2) { [0]=> RECURSION [1]=> RECURSION }
i think that here is multiple foreach need for output each ["name"] from ["subcategories"]
Now i've the following code
{foreach name=cats from=$category->name item=n}
<li>
<a href="catalog/{$n->url}" category_id="{$n->id}">
<b>{$n}</b>
</a>
</li>
{/foreach}
which displays only one Name of the current category (Soup).
How can i output each ["name"] from ["subcategories"] ?
As you said, you need a foreach for every level:
{foreach name=cats from=$category->name item=n}
<li>
<a href="catalog/{$n->url}" category_id="{$n->id}">
<b>{$n}</b>
</a>
{foreach name=subcats from=$n.subcategories item=s}
....
{/foreach}
</li>
{/foreach}
or maybe is from=$n->subcategories, I'm not sure, as you put all the array in a single line and it's difficult to see it