How to parse JSON Data in BlackBerry? [closed] - blackberry

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How to parse JSON data in BlackBerry? Need help to parse following data.
{
"menu": {
"id": "Home",
"menuitem": [
{
"type": "form",
"name": "Order",
"url": "http://domain/oredr.aspx",
"Row": [
{
"Index": "1",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "User Name"
},
{
"type": "TB",
"align": "Right",
"send": "Yes",
"param": "username",
"maxlength": "25",
"ctype": "Alpha"
}
]
},
{
"Index": "2",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Mobile No"
},
{
"type": "TB",
"align": "Right",
"send": "Yes",
"param": "MobileNo",
"maxlength": "10",
"ctype": "Numeric"
}
]
},
{
"Index": "3",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Email ID"
},
{
"type": "TB",
"align": "Right",
"send": "Yes",
"param": "email",
"maxlength": "50",
"ctype": "Email"
}
]
},
{
"Index": "4",
"Control": [
{
"type": "None",
"align": "Left",
"send": "No"
},
{
"type": "BT",
"align": "Center",
"send": "No",
"value": "Submit",
"ctype": "Submit"
}
]
}
]
},
{
"type": "form",
"value": "Stock",
"url": "http://domain/stock.aspx",
"Row": [
{
"Index": "1",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Select Medium"
},
{
"type": "CB",
"align": "Right",
"send": "Yes",
"param": "medium",
"Item": [
{
"name": "Yes"
},
{
"name": "No"
}
]
}
]
},
{
"Index": "2",
"Control": [
{
"type": "None",
"align": "Left",
"send": "No"
},
{
"type": "BT",
"align": "Center",
"send": "No",
"value": "Submit",
"ctype": "Submit"
}
]
}
]
},
{
"type": "form",
"value": "Custom",
"url": "http://domain/custom.aspx",
"Row": [
{
"Index": "1",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Offer Type"
},
{
"type": "DD",
"align": "Right",
"send": "Yes",
"param": "offertype",
"Item": [
{
"name": "Marketing"
},
{
"name": "Promotional"
}
]
}
]
},
{
"Index": "2",
"Control": [
{
"type": "None",
"align": "Left",
"send": "No"
},
{
"type": "BT",
"align": "Center",
"send": "No",
"value": "Submit",
"ctype": "Submit"
}
]
}
]
}
]
}
}

Refer this link first - json
Try this - First download json parser .jar file and import it into your project.
JSONObject data = new JSONObject(data);
JSONObject menu = data.getJSONObject("menu");
For getting a String value of a field, use the following code -
String id = menu.getString("id");
JSONObject menuitem = json.getJSONObject("menuitem");
and so on.

Related

Twilio IVR Speech Recognition

I'm new to developing IVR with twilio studio so I started with the basic template and even that's not working.
This is the log:
LOG
Split Based On...
DETAIL
Input evaluated to 'Sales.' from '{{widgets.gather_input.SpeechResult}}'
Transitioning to 'say_play_1' because 'Sales.' did not match any expression
The split is set to "Equal to" sales which then connects the call to a number. It's obviously recognizing the correct speech input but still not working. Any ideas?
{
"description": "IVR",
"states": [
{
"name": "Trigger",
"type": "trigger",
"transitions": [
{
"event": "incomingMessage"
},
{
"next": "gather_input",
"event": "incomingCall"
},
{
"event": "incomingRequest"
}
],
"properties": {
"offset": {
"x": 250,
"y": 50
}
}
},
{
"name": "gather_input",
"type": "gather-input-on-call",
"transitions": [
{
"next": "split_key_press",
"event": "keypress"
},
{
"next": "split_speech_result",
"event": "speech"
},
{
"event": "timeout"
}
],
"properties": {
"voice": "alice",
"speech_timeout": "auto",
"offset": {
"x": 290,
"y": 250
},
"loop": 1,
"hints": "support,sales",
"finish_on_key": "",
"say": "Hello, how can we direct your call? Press 1 for sales, or say sales. To reach support, press 2 or say support.",
"language": "en",
"stop_gather": false,
"gather_language": "en-US",
"profanity_filter": "false",
"timeout": 5
}
},
{
"name": "split_key_press",
"type": "split-based-on",
"transitions": [
{
"event": "noMatch"
},
{
"next": "connect_call_to_sales",
"event": "match",
"conditions": [
{
"friendly_name": "1",
"arguments": [
"{{widgets.gather_input.Digits}}"
],
"type": "equal_to",
"value": "1"
}
]
},
{
"next": "connect_call_to_support",
"event": "match",
"conditions": [
{
"friendly_name": "2",
"arguments": [
"{{widgets.gather_input.Digits}}"
],
"type": "equal_to",
"value": "2"
}
]
}
],
"properties": {
"input": "{{widgets.gather_input.Digits}}",
"offset": {
"x": 100,
"y": 510
}
}
},
{
"name": "split_speech_result",
"type": "split-based-on",
"transitions": [
{
"next": "say_play_1",
"event": "noMatch"
},
{
"next": "connect_call_to_sales",
"event": "match",
"conditions": [
{
"friendly_name": "sales",
"arguments": [
"{{widgets.gather_input.SpeechResult}}"
],
"type": "equal_to",
"value": "sales"
}
]
},
{
"next": "connect_call_to_support",
"event": "match",
"conditions": [
{
"friendly_name": "support",
"arguments": [
"{{widgets.gather_input.SpeechResult}}"
],
"type": "equal_to",
"value": "support"
}
]
}
],
"properties": {
"input": "{{widgets.gather_input.SpeechResult}}",
"offset": {
"x": 510,
"y": 510
}
}
},
{
"name": "connect_call_to_sales",
"type": "connect-call-to",
"transitions": [
{
"event": "callCompleted"
}
],
"properties": {
"offset": {
"x": 100,
"y": 750
},
"caller_id": "{{contact.channel.address}}",
"noun": "number",
"to": "12222222",
"timeout": 30
}
},
{
"name": "connect_call_to_support",
"type": "connect-call-to",
"transitions": [
{
"event": "callCompleted"
}
],
"properties": {
"offset": {
"x": 520,
"y": 750
},
"caller_id": "{{contact.channel.address}}",
"noun": "number",
"to": "12222222",
"timeout": 30
}
},
{
"name": "say_play_1",
"type": "say-play",
"transitions": [
{
"next": "gather_input",
"event": "audioComplete"
}
],
"properties": {
"offset": {
"x": 710,
"y": 200
},
"loop": 1,
"say": "not valid choice."
}
}
],
"initial_state": "Trigger",
"flags": {
"allow_concurrent_calls": true
}
}
Twilio developer evangelist here.
That is weird behaviour, mainly because the log says "evaluated to 'Sales.'". Split widgets conditions are not case-sensitive and should trim leading and following white-space. For some reason this appears to have a capital "S" and a full-stop.
I would suggest a couple of things. Firstly, raise a ticket with Twilio support to look into why the condition didn't match correctly.
Then, try some of the other conditions. When I generate a new IVR template in Studio, the conditions use "Matches any of" instead of "Equal to". You might also try "Contains".
So, experiment with the ways you can match the operators, but get support involved to drill down into why it didn't work in the first place.
The period is needed after the word for some reason...I just put both, for example:
"1, 1., Uno, Uno., Una, Una., Uno, Uno., Español, Español., Español, Español., Español, Español."

Unable to locate textfield in appium iOS using xpath and name or id is not available

Unable to locate textfield in appium iOS using xpath and name or id is not available.
These are the attributes:
[
{ "key": "elementId", "value": "1F000000-0000-0000-9F02-000000000000", "name": "elementId" },
{ "key": "type", "value": "XCUIElementTypeTextField", "name": "type" },
{ "key": "value", "value": "12B4 - 78JT - 465K - XY44", "name": "value" },
{ "key": "label", "value": "", "name": "label" },
{ "key": "enabled", "value": "true", "name": "enabled" },
{ "key": "visible", "value": "true", "name": "visible" },
{ "key": "x", "value": "30", "name": "x" },
{ "key": "y", "value": "348", "name": "y" },
{ "key": "width", "value": "315", "name": "width" },
{ "key": "height", "value": "22", "name": "height" },
{ "key": "index", "value": "3", "name": "index" }
]
And the xpath as shown in Appium Inspector is:
//XCUIElementTypeApplication[#name="Access"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeScrollView/XCUIElementTypeOther[1]/XCUIElementTypeTextField
None is helping.
I am using robot framework, appium, iOS 14.4

How to stop post request from an input section of modal in slack?

I have created a modal in slack which gets invoked upon certain command. When I submit the modal an HTTP Post request is sent to the specified URL in interactive components, but an HTTP Post request is also sent each time when I edit the assetname input column. How to stop it?
Below is the JSON which I created and also the request is not sent when making changes in any other field of the modal.
{
"type": "modal",
"title": {
"type": "plain_text",
"text": "Asset Details",
"emoji": true
},
"submit": {
"type": "plain_text",
"text": "Create Record",
"emoji": true
},
"close": {
"type": "plain_text",
"text": "Cancel",
"emoji": true
},
"blocks": [
{
"type": "divider"
},
{
"block_id": "assetname",
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "asset_name"
},
"label": {
"type": "plain_text",
"text": "Asset Name",
"emoji": true
}
},
{
"type": "input",
"block_id": "relatedguild",
"element": {
"type": "static_select",
"action_id": "guild",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "B2B Marketing Automation",
"emoji": true
},
"value": "B2B Marketing Automation"
},
{
"text": {
"type": "plain_text",
"text": "B2C Marketing Automation",
"emoji": true
},
"value": "B2C Marketing Automation"
},
{
"text": {
"type": "plain_text",
"text": "Community Cloud",
"emoji": true
},
"value": "Community Cloud"
},
{
"text": {
"type": "plain_text",
"text": "CPQ",
"emoji": true
},
"value": "CPQ"
},
{
"text": {
"type": "plain_text",
"text": "Data Analytics",
"emoji": true
},
"value": "Data Analytics"
},
{
"text": {
"type": "plain_text",
"text": "Data Core",
"emoji": true
},
"value": "Data Core"
},
{
"text": {
"type": "plain_text",
"text": "Declarative Core",
"emoji": true
},
"value": "Declarative Core"
},
{
"text": {
"type": "plain_text",
"text": "Development Process",
"emoji": true
},
"value": "Development Process"
},
{
"text": {
"type": "plain_text",
"text": "Full Stack",
"emoji": true
},
"value": "Full Stack"
},
{
"text": {
"type": "plain_text",
"text": "Non-Profit Industry",
"emoji": true
},
"value": "Non-Profit Industry"
},
{
"text": {
"type": "plain_text",
"text": "Project Management",
"emoji": true
},
"value": "Project Management"
},
{
"text": {
"type": "plain_text",
"text": "Service Cloud",
"emoji": true
},
"value": "Service Cloud"
}
]
},
"label": {
"type": "plain_text",
"text": "Related Guild",
"emoji": true
}
},
{
"type": "input",
"block_id": "cloudsImpacted",
"element": {
"type": "static_select",
"action_id": "clouds",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "None",
"emoji": true
},
"value": "None"
},
{
"text": {
"type": "plain_text",
"text": "Sales",
"emoji": true
},
"value": "Sales"
},
{
"text": {
"type": "plain_text",
"text": "Service",
"emoji": true
},
"value": "Service"
},
{
"text": {
"type": "plain_text",
"text": "Community",
"emoji": true
},
"value": "Community"
},
{
"text": {
"type": "plain_text",
"text": "Marketing",
"emoji": true
},
"value": "Marketing"
},
{
"text": {
"type": "plain_text",
"text": "Field Service",
"emoji": true
},
"value": "Field Service"
}
]
},
"label": {
"type": "plain_text",
"text": "Clouds Impacted",
"emoji": true
}
},
{
"block_id": "description",
"type": "input",
"element": {
"action_id": "descact",
"type": "plain_text_input",
"multiline": true
},
"label": {
"type": "plain_text",
"text": "Description",
"emoji": true
}
}
]
}

Adaptive Cards iOS - How do I add padding around the card edge?

I'm trying to add padding to my adaptive card view so that it's contents are inset from the edge of the card. I'd like to not adjust the padding of any of the internal card elements. I'm trying to use the following host config, which parses without error but seems to have no effect on the card.
Host config JSON:
{
"spacing": {
"small": 3,
"default": 8,
"medium": 20,
"large": 30,
"extraLarge": 40,
"padding": 100
},
"adaptiveCard": {
"allowCustomStyle": true,
"spacing": {
"padding": 100
}
}
}
Resulting card:
As you can see, there is certainly not 100px of padding being added to the card. I've used sample host configs and tweak other settings like colors so I know the config is being applied, but nothing I do seems to affect the card padding. Thanks in advance!
Card JSON:
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Publish Adaptive Card schema"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "Image",
"style": "Person",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "Small"
}
],
"width": "auto"
},
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"weight": "Bolder",
"text": "Matt Hidinger",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "None",
"text": "Created {{DATE(2017-02-14T06:08:39Z,SHORT)}}",
"isSubtle": true,
"wrap": true
}
],
"width": "stretch"
}
]
}
]
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{
"title": "Board:",
"value": "Adaptive Card"
},
{
"title": "List:",
"value": "Backlog"
},
{
"title": "Assigned to:",
"value": "Matt Hidinger"
},
{
"title": "Due date:",
"value": "Not set"
}
]
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Input.Date",
"id": "dueDate"
},
{
"type": "Input.Text",
"id": "comment",
"placeholder": "Add a comment",
"isMultiline": true
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "OK",
"url": "http://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
},
{
"type": "Action.OpenUrl",
"title": "View",
"url": "http://adaptivecards.io"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}

Swagger 2.0 - Inconsistent Results From Swagger Source

Swagger source below. When I run the swagger-tools validator, I receive no errors. When I load this in the editor, I see output but it is incorrect - it shows wrong types, and an incomplete Member object. When I try to use the code generator cli java tool, I get the following errors:
711 [main] ERROR io.swagger.models.properties.PropertyBuilder - no property for null, null
712 [main] WARN io.swagger.util.PropertyDeserializer - no property from null, null, {ENUM=null, TITLE=null, DESCRIPTION=null, DEFAULT=null, PATTERN=null, DESCRIMINATOR=null, MIN_ITEMS=null, MAX_ITEMS=null, MIN_PROPERTIES=null, MAX_PROPERTIES=null, MIN_LENGTH=null, MAX_LENGTH=null, MINIMUM=null, MAXIMUM=null, EXCLUSIVE_MINIMUM=null, EXCLUSIVE_MAXIMUM=null, UNIQUE_ITEMS=null, EXAMPLE=null, TYPE=null, FORMAT=null}
822 [main] ERROR io.swagger.codegen.DefaultCodegen - unexpected missing property for name null
822 [main] WARN io.swagger.codegen.DefaultCodegen - skipping invalid property {
"type" : "array"
}
{
"swagger": "2.0",
"info": {
"title": "V1 Inmar CRM API",
"description": "CRM API",
"version": "1.0.0"
},
"produces": ["application/json"],
"basePath": "/v1",
"paths": {
"/member": {
"get": {
"x-swagger-router-controller": "member",
"tags": ["member"],
"operationId": "GetMember",
"parameters": [
{ "$ref": "#/parameters/x-inmar-rest-api-key" },
{ "$ref": "#/parameters/x-inmar-memberID" }
],
"responses": {
"200": {
"description": "success",
"schema": { "$ref": "#/definitions/Member" }
}
}
},
"post": {
"x-swagger-route-controller": "member",
"tags": ["member"],
"operationId": "PostMember",
"parameters": [
{ "$ref": "#/parameters/x-inmar-rest-api-key" },
{ "$ref": "#/parameters/x-inmar-memberID" },
{ "$ref": "#/parameters/member" }
],
"responses": {
"200": { "$ref": "#/responses/generic-200" }
}
}
}
},
"parameters": {
"x-inmar-rest-api-key": {
"name": "X-Inmar-REST-API-Key",
"description": "API Access Key.",
"in": "header",
"required": true,
"type": "string"
},
"x-inmar-memberID": {
"name": "X-Inmar-MemberID",
"description": "Unique ID for member.",
"in": "header",
"required": true,
"type": "string"
},
"member": {
"description": "member object",
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/Member"
}
}
},
"responses": {
"generic-200": {
"description": "Success"
}
},
"definitions": {
"Member": {
"description": "member",
"type": "object",
"properties": {
"active": {
"type": "boolean",
"default": true
},
"identity": {
"type": "object",
"required": [
"user_id"
],
"properties": {
"user_id": {
"type": "string",
"maxLength": 50,
"format": "email"
},
"password": {
"type": "string",
"minLength": 8,
"maxLength": 20
},
"proxy_id": {
"type": "integer"
}
}
},
"pii": {
"type": "object",
"description": "personally_identifiable_information.",
"properties": {
"alt_email": {
"type": "string",
"description": "Secondary email addresses that may or may not match the id.",
"format": "email"
},
"first_name": {
"type": "string",
"minLength": 1,
"maxLength": 25
},
"last_name": {
"type": "string",
"minLength": 1,
"maxLength": 25
},
"primary_address_one": {
"type": "string",
"minLength": 1,
"maxLength": 47
},
"primary_address_two": {
"type": "string",
"minLength": 1,
"maxLength": 47
},
"primary_address_city": {
"type": "string",
"minLength": 1,
"maxLength": 47
},
"primary_address_state": {
"type": "string",
"minLength": 2,
"maxLength": 2,
"description": "US states and US territories and Canadian provinces.",
"enum": [
"AA",
"AB",
"AE",
"AK",
"AL",
"AP",
"AR",
"AS",
"AZ",
"BC",
"CA",
"CO",
"CT",
"DC",
"DE",
"FL",
"FM",
"GA",
"GU",
"HI",
"IA",
"ID",
"IL",
"IN",
"KS",
"KY",
"LA",
"MA",
"MB",
"MD",
"ME",
"MH",
"MI",
"MN",
"MO",
"MP",
"MS",
"MT",
"NB",
"NC",
"ND",
"NE",
"NH",
"NJ",
"NL",
"NM",
"NS",
"NT",
"NU",
"NV",
"NY",
"OH",
"OK",
"ON",
"OR",
"PA",
"PE",
"PR",
"PW",
"QC",
"RI",
"SC",
"SD",
"SK",
"TN",
"TX",
"UK",
"UT",
"VA",
"VI",
"VT",
"WA",
"WI",
"WV",
"WY",
"YT"
]
},
"primary_address_postal_code": {
"type": "string",
"minLength": 5,
"maxLength": 10
},
"primary_address_country": {
"type": "string",
"enum": [
"US",
"CA"
]
},
"birthdate": {
"type": "string"
},
"language_preference": {
"type": "string"
},
"gender": {
"type": "string",
"enum": [
"male",
"female"
]
}
}
},
"profiles": {
"type": "array",
"items": {
"properties": {
"site_id": {
"type": "integer"
},
"survey_data": {
"type": "object",
"required": [
"survey_id",
"survey_responses"
],
"properties": {
"survey_id": {
"type": "integer",
"description": "Unique identifier of a profile survey."
},
"survey_responses": {
"type": "array",
"items": {
"required": [
"question_id",
"response_id",
"free_form_value"
],
"properties": {
"question_id": {
"type": "integer",
"description": "Unique identifier of a profile survey question."
},
"response_id": {
"type": "integer",
"description": "Unique identifier of a profile question response.",
"default": 0
},
"free_form_value": {
"type": "string",
"description": "Consumer free form response",
"default": ""
}
}
}
}
}
}
}
}
},
"optins": {
"type": "array",
"items": {
"$ref": "#/definitions/OptIn"
}
}
}
},
"OptIn": {
"description": "survey response",
"type": "object",
"properties":{
"optin_id": {
"type": "integer",
"description": "Unique identifier of an opt in question/choice. e.g. newsletter"
},
"optin_value": {
"type": "integer",
"enum": [ 0, 1 ],
"description": "Optin Response of 0=Optout and 1=Optin"
}
},
"required": [
"optin_id",
"optin_value"
]
}
}
}

Resources