Uncaught Error: You're trying to decode an invalid JSON String - json

I have facing problems with EXT js code to store data using Java.
Below is my code. Can one please help me.
Below is my NewCustomersVerify.js code:
var myHit = Ext.create('Ext.data.Store',{
fields:['Id','Name'],
data:[
{Id:'0',Name:'No'},
{Id:'1',Name:'Yes'}
]
});
var myRisk = Ext.create('Ext.data.Store',{
fields:['Id','Name'],
data:[
{Id:'0',Name:'Low'},
{Id:'1',Name:'High'}
]
});
Ext.define('Test.test.web.test.view.test.NewCustomersVerify', {
"xtype": "newCustomersVerify",
"items": [{
"xtype": "panel",
"items": [{
"xtype": "panel",
"items": [{
"xtype": "displayfield",
"fieldLabel": "Name :",
"margin": 5,
"value": "TEXT",
"name": "customerName",
"title": "Customer Name",
"itemId": "lnajnbi", "bind": "{customerName}"
},{
"xtype": "displayfield",
"fieldLabel": "Nationality :",
"margin": 5,
"value": "TEXT",
"name": "nationality",
"title": "Nationality",
"itemId": "lnbjnbi", "bind": "{nationality}"
},{
"xtype": "displayfield",
"fieldLabel": "UniqueId No :",
"margin": 5,
"value": "TEXT",
"name": "uniqueIdNo",
"title": "UniqueId No",
"itemId": "lncjnbi", "bind": "{uniqueIdNo}"
},{
"xtype": "hiddenfield",
"fieldLabel": "HiddenText",
"bindable": "contactId",
"margin": 5,
"name": "contactId",
"title": "HiddenText",
"itemId": "oidgafi",
"bind": "{contactId}"
},{
"xtype": "hiddenfield",
"fieldLabel": "HiddenText",
"bindable": "screeningId",
"margin": 5,
"name": "screeningId",
"title": "HiddenText",
"itemId": "didgafi",
"bind": "{screeningId}"
}],
"layout": "vbox",
"autoScroll": true,
"margin": 5,
"columnWidth": 0.5,
"itemId": "cieadni",
"dockedItems": []
}, {
"xtype": "panel",
"items": [
{
"xtype": "combo",
"fieldLabel": "Was there a verify hit?",
"name": "screeningHit",
"margin": 5,
"bindable": "screeningHit",
"title": "Was there a verify hit?",
"columnWidth": 0.5,
"width": "100",
"labelAlign": "left",
"itemId": "kbfmjgi",
displayField:'Name',
valueField:'Id',
queryMode:'local',
store: myHit,
}, {
"xtype": "combo",
"fieldLabel": "Country Risk (Nationality)",
"name": "countryRisk",
"margin": 5,
"bindable": "countryRisk",
"title": "Country Risk (Nationality)",
"columnWidth": 0.5,
"width": "100",
"labelAlign": "left",
"itemId": "kbgajgi",
displayField:'Name',
valueField:'Id',
queryMode:'local',
store: myRisk
}, {
"xtype": "combo",
"fieldLabel": "Occupation Risk",
"name": "occupationRisk",
"margin": 5,
"bindable": "occupationRisk",
"title": "Occupation Risk",
"columnWidth": 0.5,
"width": "100",
"labelAlign": "left",
"itemId": "kbaajgi",
displayField:'Name',
valueField:'Id',
queryMode:'local',
store: myRisk
}, {
"xtype" : "filefield",
"fieldLabel": "Upload evidence of verify (Screenshot from the verify portal)",
"msgTarget" : "side",
"allowBlank" : "false",
"buttonOnly" : "true",
"margin" : 5,
"name" : "uploadFile",
buttonConfig : {
"text" : "Upload",
"icon" : "images/cloud/upload.png",
},
listeners : {
change :"uploadFile"
}
}],
"layout": "vbox",
"autoScroll": true,
"margin": 5,
"columnWidth": 0.5,
"itemId": "nehbeki",
"dockedItems": []
}],
"layout": "column",
"autoScroll": true,
"border": true,
"margin": 5,
"itemId": "gjihcpi",
"dockedItems": [{
"xtype": "toolbar",
"dock": "bottom",
"ui": "footer",
"isToolBar": true,
"isDockedItem": true,
"items": [{
"xtype": "tbfill",
"itemId": "hajhegi"
},
/* {
"xtype": "button",
"name": "cancel",
"text": "Cancel",
"margin": 5,
"isResetButton": true,
"itemId": "bbkmkmi",
"listeners": {
"click": "oncancelclick"
}
},*/
{
"xtype": "button",
"name": "Confirm",
"text": "Confirm",
"margin": 5,
"itemId": "celbgji",
"listeners": {
"click": "onConfirmclick"
}
}],
"columnWidth": 0.5,
"itemId": "lfmepni",
"dockedItems": []
}]
}],
"border": true,
"autoScroll": false,
// "title": "New Customer Verify",
"margin": 5,
"itemId": "dinfmki",
"dockedItems": [],
"extend": "Ext.form.Panel",
"listeners": {
"afterrender": "onafterrender",
"scope": "controller"
},
"requires": ["Test.test.web.test.controller.test.NewCustomersVerifyController", "Test.test.shared.test.viewmodel.test.NewCustomersVerifyViewModel", "Test.test.shared.test.model.test.NewCustomersVerifyModel"],
"viewModel": "NewCustomersVerifyViewModel",
"controller": "NewCustomersVerifyController"
});
Below is my button onConfirmclick function call on NewCustomersVerifyContoller.js
onConfirmclick: function(me, e, eOpts) {
var jsonData = {};
jsonData.contactId = this.view.down('#oidgafi').getValue();
jsonData.screeningId = this.view.down('#didgafi').getValue();
jsonData.screeningHit = this.view.down('#kbfmjgi').getValue();
jsonData.countryHit = this.view.down('#kbgajgi').getValue();
jsonData.occupationHit = this.view.down('#kbaajgi').getValue();
var scope = this.getView();
Ext.MessageBox.show({
msg : 'Saving data...',
progressText : 'Saving...',
width : 300,
wait : true,
waitConfig : {
interval : 200
}
});
Ext.Ajax.request({
url: 'secure/NewCustomersVerifyServiceWS/respond',
method: 'POST',
sender: scope,
jsonData: jsonData,
me: me,
success: function(response, scope) {
Ext.MessageBox.hide();
responseData = Ext.JSON.decode(response.responseText);
Ext.Msg.alert('Server Response', responseData.response.message);
win = scope.sender.up();
win.reportViewController.queryCriteria.controller.filterData(win.searchButtonRef);
win.close();
},
failure: function(response, scope) {
Ext.MessageBox.hide();
responseData = Ext.JSON.decode(response.responseText);
Ext.Msg.alert('Server Response', responseData.response.message);
}
}, scope);
}
Below is the error i was getting on the browser console.
[E] Ext.JSON.decode(): You're trying to decode an invalid JSON String:
Apache Tomcat/8.0.21 - Error
reportH1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}.line {height: 1px;
background-color: #525D76; border: none;}
HTTP Status 400 - type Status reportmessage
description The request sent by the client was
syntactically incorrect.Apache
Tomcat/8.0.21

Error is on Ajax success or failure function. You are trying to decode invalid json which is passed from your controller (or middle layer server). You need to console the response before decode any string.
Just add console log before Ext.decode(). and post response here. That will solve your problem.

thank you for your support.
I have declared the variable occupationRisk as **occupationHit **.
That's the problem... Now its solved.

Related

Parsing a list of images from NOTION database to flutter app

I am trying to display Notion content such as texts, dates, booleans and images on flutter app.. For texts, dates, and booleans, everything is working.. but I am stuck at displaying images. Please kindly take a look at my JSON file and my code.. and let me know where I am doing wrong..
JSON file that I got from my Notion database
{
"object": "list",
"results": [
{
"object": "page",
"id": "0f2aad20-225a-4d40-b853-fb5943e01636",
"created_time": "2022-09-01T05:14:00.000Z",
"last_edited_time": "2022-09-03T09:56:00.000Z",
"created_by": {
"object": "user",
"id": "33138aa4-0670-49f9-a118-daaef0698369"
},
"last_edited_by": {
"object": "user",
"id": "33138aa4-0670-49f9-a118-daaef0698369"
},
"cover": null,
"icon": null,
"parent": {
"type": "database_id",
"database_id": "f24cee3c-bd2f-466a-bc5f-a505e83b348f"
},
"archived": false,
"properties": {
"Price Range": {
"id": "BiJQ",
"type": "select",
"select": {
"id": "]erF",
"name": "< 2000 Lakh",
"color": "default"
}
},
"On Market": {
"id": "Bxp%60",
"type": "checkbox",
"checkbox": false
},
"Longitude ": {
"id": "CGYh",
"type": "number",
"number": 96.113146
},
"Asking Price in Lakh": {
"id": "Gv%7D%7D",
"type": "number",
"number": 590
},
"Township": {
"id": "MP%7D%3D",
"type": "select",
"select": {
"id": "qwfy",
"name": "Mingaladon - YGN",
"color": "default"
}
},
"Owner Phone": {
"id": "Mqhp",
"type": "phone_number",
"phone_number": "09448840549"
},
"Images": {
"id": "OLC%3B",
"type": "files",
"files": [
{
"name": "31_AUG-22.jpg",
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/04b39e7e-c2c4-4ccd-a653-348933fa613e/31_AUG-22.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220903%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220903T102952Z&X-Amz-Expires=3600&X-Amz-Signature=2db13c256bfd191fc3fbc0941438a4a1c75a8da128b6f69b6e2a63002140327b&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-09-03T11:29:52.168Z"
}
},
{
"name": "31_AUG-21.jpg",
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/06ce697d-af96-4f3e-b26e-bc092cacfdf8/31_AUG-21.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220903%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220903T102952Z&X-Amz-Expires=3600&X-Amz-Signature=33d5c21d71113008f3fbc4f95bf311515e4d42a3eb1f8c6c10fccc355e4e2d9a&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-09-03T11:29:52.209Z"
}
},
{
"name": "31_AUG-23.jpg",
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/32ec9466-fe8a-4eb9-8c1b-0d0abbe8637b/31_AUG-23.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220903%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220903T102952Z&X-Amz-Expires=3600&X-Amz-Signature=059545c77b9a2330483d34292d2b7e4503d3e9f7ceac67cd44f63d56d6d8a0f0&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-09-03T11:29:52.271Z"
}
}
]
},
"Zone": {
"id": "O_ui",
"type": "select",
"select": {
"id": "bWGg",
"name": "13",
"color": "default"
}
},
"Progress": {
"id": "P%3C%7BM",
"type": "multi_select",
"multi_select": []
},
"Category": {
"id": "PM%5EA",
"type": "select",
"select": {
"id": "kLgI",
"name": "Residential",
"color": "default"
}
},
"Status": {
"id": "R%7B%5Dl",
"type": "select",
"select": {
"id": ":huS",
"name": "For Sale",
"color": "default"
}
},
"Latitude ": {
"id": "TUmm",
"type": "number",
"number": 16.955839
},
"Flooring": {
"id": "U%3FS%5D",
"type": "rich_text",
"rich_text": []
},
"Bathroom": {
"id": "WPEe",
"type": "number",
"number": 1
},
"Price Per Sqft": {
"id": "%5C%3Alg",
"type": "number",
"number": 21000
},
"Address": {
"id": "%5DSz%7C",
"type": "rich_text",
"rich_text": [
{
"type": "text",
"text": {
"content": "Mingalardon, ဝါယာလက် , တောတိုက်ရပ်ကွက်, အမှတ် ၇/၄၉",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "Mingalardon, ဝါယာလက် , တောတိုက်ရပ်ကွက်, အမှတ် ၇/၄၉",
"href": null
}
]
},
"Type": {
"id": "%5E%3E%40F",
"type": "select",
"select": {
"id": "Hb_}",
"name": "House",
"color": "default"
}
},
"State": {
"id": "%5E%7DP%60",
"type": "select",
"select": {
"id": ":fMv",
"name": "YGN",
"color": "default"
}
},
"Year Built": {
"id": "a%5C%5Ce",
"type": "number",
"number": 2014
},
"Data Source": {
"id": "awp%5B",
"type": "select",
"select": {
"id": "Ohch",
"name": "Facebook",
"color": "default"
}
},
"Electricity": {
"id": "bCpc",
"type": "select",
"select": {
"id": "=^]Q",
"name": "1 Single",
"color": "default"
}
},
"Cover Photo": {
"id": "bDDW",
"type": "files",
"files": [
{
"name": "31_AUG-21.jpg",
"type": "file",
"file": {
"url": "https://s3.us-west-2.amazonaws.com/secure.notion-static.com/b2784859-34d3-41c2-a88a-3311d8886804/31_AUG-21.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220903%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220903T102952Z&X-Amz-Expires=3600&X-Amz-Signature=eb7ab8e22917357922dfa939c250c5106f8e496888b564f17c622d804045f4ff&X-Amz-SignedHeaders=host&x-id=GetObject",
"expiry_time": "2022-09-03T11:29:52.297Z"
}
}
]
},
"Contact": {
"id": "d_%5E%3E",
"type": "relation",
"relation": []
},
"Car Parking": {
"id": "gIBP",
"type": "number",
"number": 2
},
"Water System": {
"id": "gfRJ",
"type": "multi_select",
"multi_select": [
{
"id": "08a52b0a-cbbf-4e7d-8756-c2edb40a8ed9",
"name": "ဂျိုးဖြူရေ",
"color": "gray"
}
]
},
"Sold Date": {
"id": "giQA",
"type": "date",
"date": null
},
"Air Con": {
"id": "mP%5Dd",
"type": "number",
"number": 0
},
"Bedrooms": {
"id": "ptfQ",
"type": "select",
"select": {
"id": "O}`U",
"name": "3",
"color": "default"
}
},
"Owner Direct": {
"id": "py%40O",
"type": "checkbox",
"checkbox": false
},
"Lot Size (Sqft)": {
"id": "t%3AwQ",
"type": "number",
"number": 2795
},
"Type of Ownership": {
"id": "vgED",
"type": "select",
"select": {
"id": "37a4fbaa-955f-48d0-9a4d-4f5a28a8ca9a",
"name": "အရပ်စာချုပ်",
"color": "red"
}
},
"Added Time": {
"id": "x%3Byd",
"type": "last_edited_time",
"last_edited_time": "2022-09-03T09:56:00.000Z"
},
"ခြံအကျယ် (ပေ)": {
"id": "z%3D%3D%40",
"type": "rich_text",
"rich_text": [
{
"type": "text",
"text": {
"content": "43x65",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "43x65",
"href": null
}
]
},
"Structure": {
"id": "%7Cj%5Er",
"type": "select",
"select": {
"id": "ad149505-37a9-4464-8d13-7ff1e34cef3f",
"name": "ပျဉ်ထောင်အိမ်",
"color": "blue"
}
},
"Property Title": {
"id": "%7Cn%3F%3E",
"type": "rich_text",
"rich_text": [
{
"type": "text",
"text": {
"content": "မင်္ဂလာဒုံမြို့နယ်တောတိုက်ရပ်ကွက် ရှိ အိမ်လေးတစ်လုံးရောင်းရန်ရှိ",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "မင်္ဂလာဒုံမြို့နယ်တောတိုက်ရပ်ကွက် ရှိ အိမ်လေးတစ်လုံးရောင်းရန်ရှိ",
"href": null
}
]
},
"360 Photo ": {
"id": "~yOp",
"type": "url",
"url": "https://kuula.co/share/collection/7vSsM?logo=0&info=1&fs=1&vr=0&sd=1&thumbs=1"
},
"Name": {
"id": "title",
"type": "title",
"title": [
{
"type": "text",
"text": {
"content": "YGN-13C-06",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "YGN-13C-06",
"href": null
}
]
}
},
"url": "https://www.notion.so/YGN-13C-06-0f2aad20225a4d40b853fb5943e01636"
},
How I get data from Notion
class NotionAPI {
final http.Client _client;
static const String _baseUrl = 'https://api.notion.com/v1/';
NotionAPI({http.Client? client}) : _client = client ?? http.Client();
void dispose() {
_client.close();
}
Future<List<NotionPropertyModel>> getProperties() async {
try {
final url =
'${_baseUrl}databases/${dotenv.env['NOTION_DATABASE_ID']}/query';
final response = await _client.post(
Uri.parse(url),
headers: {
HttpHeaders.authorizationHeader:
'Bearer ${dotenv.env['NOTION_API_KEY']}',
'Notion-Version': '2022-06-28',
},
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body) as Map<String, dynamic>;
return (data['results'] as List)
.map((e) => NotionPropertyModel.fromMap(e))
.toList()
..sort((a, b) => b.date.compareTo(a.date));
} else {
throw const Failure(message: 'Something went wrong..STW!');
}
} catch (_) {
throw const Failure(message: 'Something went wrong..++++!');
}
}
}
My fromJson method
factory NotionPropertyModel.fromMap(Map<String, dynamic> map) {
final properties = map['properties'] as Map<String, dynamic>;
final dateStr = properties['Date']?['date']?['start'];
return NotionPropertyModel(
pptID: properties['Name']?['title']?[0]?['plain_text'] ?? '?',
date: dateStr != null ? DateTime.parse(dateStr) : DateTime.now(),
dataSource: properties['Data Source']?['select']?['name'] ?? 'Any',
ownerDirect: properties['Owner Direct']?['checkbox'] as bool,
priceInLakh:
(properties['Asking Price in Lakh']?['number'] ?? 0).toDouble(),
coverPhoto: properties['Cover Photo']?['files']?['file']?['url'],
);
}
How I display on the screen
child: Column(
children: [
Image.network(itemData.coverPhoto),
Text(itemData.pptID),
Text(itemData.dataSource),
if (itemData.ownerDirect == true)
const Text(
'Owner Direct',
style: TextStyle(fontSize: 20),
)
],
),
Your cover image is a list of file so change this:
coverPhoto: properties['Cover Photo']?['files']?['file']?['url'],
to
factory NotionPropertyModel.fromMap(Map<String, dynamic> map) {
final properties = map['properties'] as Map<String, dynamic>;
final dateStr = properties['Date']?['date']?['start'];
List coverList = properties['Cover Photo']?['files'] ?? [];
return NotionPropertyModel(
pptID: properties['Name']?['title']?[0]?['plain_text'] ?? '?',
date: dateStr != null ? DateTime.parse(dateStr) : DateTime.now(),
dataSource: properties['Data Source']?['select']?['name'] ?? 'Any',
ownerDirect: properties['Owner Direct']?['checkbox'] as bool,
priceInLakh:
(properties['Asking Price in Lakh']?['number'] ?? 0).toDouble(),
coverPhoto: (coverList != null && coverList.isNotEmpty) ? coverList[0]['file']?['url'] : '',
);
}

Extract some value from JSON using JsonPath with != condition in Jmeter

I have the following JSON and I need to get id values for instances which do not have type = Jenkins
{
"data": [
{
"id": "35002399-6fd7-40b7-b0d0-8be64e4ec09c",
"name": "94Jenkins",
"url": "http://127.0.0.1:8084",
"authProvider": false,
"siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
"status": {
"status": "ONLINE"
},
"instanceStateReady": true,
"instanceState": {
"#type": "InstanceStateDto",
"version": "2.60.3"
},
"adminUser": "admin1",
"hasDRConfig": false,
"managed": true,
"type": "JENKINS",
"siteName": "City",
"lastRefreshTime": "2018-04-24T09:43:01.694Z"
},
{
"id": "5cd3caf6-bac1-4f07-8793-5f124b90eaf5",
"name": "RJO",
"url": "http://test.com",
"authProvider": false,
"status": {
"status": "UNAUTHORIZED"
},
"instanceStateReady": true,
"instanceState": {
"#type": "numberOfArtifacts",
"version": "5.5.2-m002",
"licenses": {
"RJO : artrjo-m": {
"type": "ENTERPRISE",
"validThrough": "Jun 12, 2021",
"licensedTo": "Test",
"licenseHash": "asdadsdb612bda1aae745bd2a3",
"expired": false
},
"RJO : artrjo-s1": {
"type": "ENTERPRISE",
"validThrough": "Jun 12, 2021",
"licensedTo": "JFrog",
"licenseHash": "asaswca236350205a3798c0fa3",
"expired": false
}
}
},
"adminUser": "jfmc",
"hasDRConfig": false,
"managed": false,
"warnings": [
"Site is missing",
"Failed to connect to the service. Please verify that the service information provided is correct."
],
"type": "ARTIFACTORY"
},
{
"id": "0727a49a-6c95-433e-9fc5-7e5c760cc76f",
"name": "NinetyTwo",
"url": "http:127.0.0.1:8081",
"authProvider": true,
"siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
"status": {
"status": "ONLINE"
},
"instanceStateReady": true,
"instanceState": {
"#type": "numberOfArtifacts",
"version": "5.9.0",
"licenses": {
"NinetyTwo": {
"type": "ENTERPRISE",
"validThrough": "Dec 30, 2018",
"licensedTo": "Test",
"licenseHash": "qweqwed95f712dbabee98184da52443",
"expired": false
}
}
},
"adminUser": "admin",
"hasDRConfig": false,
"managed": true,
"type": "ARTIFACTORY",
"serviceId": "jfrt#01c7g4c7hq0dpd0qa71r8c09sj",
"siteName": "Test",
"lastRefreshTime": "2018-04-24T09:43:01.698Z"
}
]
}
And I use $..[?(#.type!='JENKINS')].id path to receive id-s which relate to the instances with type NOT JENKINS, however JSON Extractor returns me the Jenkins's id too. The question is how can I receive ids for non-jenkins instances only?
Replace your JSON path expression with the below and it should work:
$.data.[*][?(#.type != "JENKINS")].id

Returning metadata value from JSON API Response

I have an api request that returns JSON data which is then used to populate an html table. I am able to populate the table with item.name ... I would like to add the metadata value for player.field but I have not been able to access it. Here is the JSON response:
{
"list": [
{
"id": 55,
"name": "0046GS (RMS03241708)",
"description": "S 12-7 M-S 10-9",
"uuid": "6f4b5bfd-6d17-4095-9e48-7b9313f7f8c6",
"previewPlayer": false,
"enabled": true,
"mac": "00-00-00-00-00-00",
"type": "CHROMEBOX",
"distributionServer": {
"id": 2,
"name": "Main",
"driver": "IP_P2P"
},
"playergroups": [
{
"id": 2,
"name": "GameStop",
"numberOfPlayers": 454
}
],
"playerDisplays": [
{
"id": 55,
"name": "Display 1",
"channel": {
"id": 53,
"name": "GameStop TV"
},
"screenCounter": 1
}
],
"requestLogs": false,
"downloadThreads": 1,
"unusedFilesCache": 24,
"planDeliveryMethod": "CONTENT_MANAGER_DIRECT",
"pollingInterval": 1,
"pollingUnit": "MINUTES",
"logLevel": "normal",
"metadataValue": [
{
"id": 12512,
"value": "true",
"playerMetadata": {
"id": 34,
"name": "Player.field",
"datatype": "BOOLEAN",
"valueType": "ANY",
"order": 4
}
},
{
"id": 1085,
"value": "77056",
"playerMetadata": {
"id": 31,
"name": "Player.ZipCode",
"datatype": "STRING",
"valueType": "ANY",
"order": 30
}
},
{
"id": 1071,
"value": "22:15",
"playerMetadata": {
"id": 10,
"name": "Player.ScreenOff_Wednesday",
"datatype": "STRING",
"valueType": "ANY",
"order": 12
}
}
],
"usedPairingKey": "HBVULW",
"active": "ACTIVE",
"lastModified": "2017-04-03 20:12:43",
"timezoneOffset": "0"
}
],
"offset": 0,
"count": 68
}
Here is the ajax request:
$.ajax({
type: 'GET',
url: "https://sampleserver.com:8080/ContentManager/api/rest/players?limit=1&offset=0&sort=name&filters=%7BplayerStatus%20:%20%7Bvalues:%5B'ACTIVE'%5D,%20comparator%20:%20'eq'%7D%7D",
dataType: "json",
success: function(data) {
$.each(data.list, function(i, item) {
var tr = $('<tr><td>'+item.name+'</td><td>'+some.JSONResponse+'</td></tr>').appendTo('#scalaapi');
});
}
});
I am stuck on how to specifically display the value for player.field ... "value": "true",
It feels like it should be simple, but my attempts have all been met with undefined.
Attempted if statement...
success: function(data) {
$.each(data.list, function(i, item) {
var tr = $('<tr><td>'+item.name+'</td><td class="val">...</td></tr>').appendTo('#scalaapi');
var bool = function(i,item) {if (item.metadataValue.id = '12512');
tr.find('.val').text(bool);};
});
}
});

Json data is not populated in treeview panel

here below is my json formate i need to show in the treeview panel in extjs6
After loading store from server i am not able to see any records in Tree panel.
what should be the Model view and store for this json rendering in to the Tree view panel .
Thanks.
here is my code :
Model :
Ext.define('File', {
extend: 'Ext.data.TreeModel',
fields: [
{number: 'number', type: 'string'},
]
});
Store :
var store = Ext.create('Ext.data.TreeStore', {
model: 'File',
proxy: {
type: 'ajax',
url: 'component-tree.json',
reader: {
type: 'json',
rootProperty: 'components',
leaf: true,
children: 'components',
expanded: true,
},
},
folderSort: true,
});
View :
var tree = Ext.create('Ext.tree.Panel', {
autoLoad: true,
collapsible: true,
useArrows: true,
rootVisible: true,
store: store,
multiSelect: true,
width: 250,
height: 300,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
appendOnly: true
}
},
root: {
text: "Components",
expanded: true,
},
renderTo: document.body
});
component-tree.json :
{
"components": {
"state": "RELEASED",
"nodeType": "Component",
"checked": true,
"name": "PLATE - FOR CABINET - ASSEMBLY",
"level": 0,
"url": "http://example.com/Windchill/servlet/nexiles/tools/api/1.0/epmdocuments/OR:wt.epm.EPMDocument:4474031",
"oid": "OR:wt.epm.EPMDocument:4474031",
"modified": "17.04.2015",
"filename": "21378386.asm",
"num_children": 7,
"number": "21378386.ASM",
"details": "http://example.com/Windchill/app/#ptc1/tcomp/infoPage?oid=OR:wt.epm.EPMDocument:4474031&u8=1",
"components": [
{
"nodeType": "Component",
"leaf": true,
"name": "PLATE - FOR CABINET - DETAIL",
"level": 1,
"url": "http://example.com/Windchill/servlet/nexiles/tools/api/1.0/epmdocuments/OR:wt.epm.EPMDocument:4474018",
"oid": "OR:wt.epm.EPMDocument:4474018",
"modified": "17.04.2011",
"filename": "1234.prt",
"state": "RELEASED",
"number": "21378385.PRT",
"details": "http://example.com/Windchill/app/#ptc1/tcomp/infoPage?oid=OR:wt.epm.EPMDocument:4474018&u8=1",
"version": "A",
"checked": true,
"drawings": [
{
"reftype": "DRAWING",
"nodeType": "Drawing",
"leaf": true,
"name": "PLATE - FOR CABINET - DETAIL",
"url": "http://example.com/Windchill/servlet/nexiles/tools/api/1.0/epmdocuments/OR:wt.epm.EPMDocument:4474013",
"oid": "OR:wt.epm.EPMDocument:4474013",
"modified": "17.04.2015",
"filename": "21378385.drw",
"source": "representation",
"state": "RELEASED",
"number": "21378385.DRW",
"details": "http://example.com/Windchill/app/#ptc1/tcomp/infoPage?oid=OR:wt.epm.EPMDocument:4474013&u8=1",
"version": "A",
"checked": true,
"id": "OR:wt.epm.EPMDocument:4474013-DRAWING",
"icon": "/resources/images/drawing.gif"
},
{
"reftype": "INTERNAL",
"nodeType": "Drawing",
"leaf": true,
"name": "PLATE - FOR CABINET - ASSEMBLY",
"url": "http://example.com/Windchill/servlet/nexiles/tools/api/1.0/epmdocuments/OR:wt.epm.EPMDocument:4474041",
"oid": "OR:wt.epm.EPMDocument:4474041",
"modified": "17.04.2015",
"filename": "21378386.drw",
"source": "representation",
"state": "RELEASED",
"number": "21378386.DRW",
"details": "http://example.com/Windchill/app/#ptc1/tcomp/infoPage?oid=OR:wt.epm.EPMDocument:4474041&u8=1",
"version": "A",
"checked": true,
"id": "OR:wt.epm.EPMDocument:4474041-INTERNAL",
"icon": "/resources/images/drawing.gif"
}
],
"icon": "/resources/images/prt_image.gif"
}
}
Your treeModel just defines number but your store actually contains much more fields...
Take a look at the doc in the chapter 'Heterogeneous node types' for more information.
Try with children instead of components in your json file. By the way I could remark that the case is not respected between the configuration root: { text: "Components", ... } and the json content "components": [ ... ].
C and c

Using multiple amcharts in a single sammy js view

Using the following Sammy JS view, AmCharts and JSON, I'm trying to load more than one graph into the "insights" view:
this.get('#/insights', function (context) {
context.$element().html("<div id='chartdiv'></div>");
var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme": "none",
"titles": [{
"text": "Header Text",
"size": 16
}],
"dataProvider": [{
"product": "Product 1",
"value": 23
}, {
"product": "Product 2",
"value": 56
}, {
"product": "Product 3",
"value": 21
}],
"titleField": "product",
"valueField": "value",
"labelRadius": 5,
"startEffect": "bounce",
"startDuration": 2,
"labelRadius": 15,
"radius": "22%",
"innerRadius": "60%",
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>"
//"labelText": "[[title]]"
});
});
I tried adding another div into:
context.$element().html("<div id='chartdiv'></div><div id='chartdiv2'></div>");
with associated amcharts data:
var chart = AmCharts.makeChart("chartdiv2", {
"type": "pie",
"theme": "none",
"titles": [{
"text": "Header Text",
"size": 16
}],
"dataProvider": [{
"product": "Product 1",
"value": 23
}, {
"product": "Product 2",
"value": 56
}, {
"product": "Product 3",
"value": 21
}],
"titleField": "product",
"valueField": "value",
"labelRadius": 5,
"startEffect": "bounce",
"startDuration": 2,
"labelRadius": 15,
"radius": "22%",
"innerRadius": "60%",
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>"
//"labelText": "[[title]]"
});
});
I can't seem to get the second graph to display.
I have used multiple piecharts this way, you can refer to my code below:-
/*
This code block i have used in php for dynamic data, you can ignore this block.
This is just to give you an idea about i am using data to populate the chart.
*/
$return['chartdata'] = $dataset;
$return['titlefield'] = $_POST['display_field'];
$return['valuefield'][] = 'count';
$return['valuefield'][] = 'value';
echo json_encode($return);
/*
Ends Here.
*/
/* Below code is what will help you. */
for (var i = 0; i < result.valuefield.length; i++) {
$('#charts_div').append("<div class='col-md-6'><div id='chartdiv"+(i+1)+"' style='width: 640px; height: 400px;'></div></div>");
var chart = new AmCharts.AmPieChart();
chart.pathToImages = gbl_js+"amcharts/images/";
chart.dataProvider = result.chartdata;
chart.titleField = result.titlefield;
chart.valueField = result.valuefield[i];
chart.legend = {
"markerType": "circle",
"position": "bottom",
"marginRight": 80,
"autoMargins": false,
"valueText": ""
};
chart.exportConfig = {
"menuTop": 0,
"menuItems": [{
"icon": gbl_js+'amcharts/images/export.png',
"items": [{
"title": 'JPG',
"format": 'jpg'
}, {
"title": 'PNG',
"format": 'png'
}, {
"title": 'SVG',
"format": 'svg'
}, {
"title": 'PDF',
"format": 'pdf'
}]
}
};
chart.write('chartdiv'+(i+1));
};