How to get values in this json object in ext js? - json

I try to get values and put in a textfield. return json is ;
Object { info=[1]}
in this
info[Object { name="name", another ="another"}]
clearly ;
{"info":[{"name":"name","another":"another"}]}
i do ;
var resp = Ext.decode(response.responseText);
txtName.setValue(resp.info);
and in text field it shown [Object object]
How to i get name and another values?

Because response.info is a root level node in your response which contains an array of objects:
[{"name":"name","another":"another"}]
So to use a value from this object in the text box (as it needs a string value) you need to access the object in this array and then extract the value from whichever key you want so to get the name value in the text field you would use:
txtName.setValue(resp.info[0].name);
As a side note, usually you would use an ExtJS Store with a proxy configured to retrieve and store data from the server (if returned in this type of JSON like structure). On the store config you would configure the root property to the tell the store reader which named property in the response contains the data. So in this case 'info' is the root where your data can then be found. The store reader would then loop through the objects in the array and create records for each in the store for the rest of the application to use.

Related

How to get the data in front end when API calling returning data in [[101,4],[102,2],[103,1],[104,1],[105,1],[108,1],[109,1]] without key value pair?

When I am calling API its giving data in [[101,4],[102,2],[103,1],[104,1],[105,1],[108,1],[109,1]] format which is only value. Is there any solution that how to get this data in UI in flutter?
Previously I have worked with below type of data coming from API.In this data can be accessed using key name but how to access value in [[101,4],[102,2],[103,1],[104,1],[105,1],[108,1],[109,1]] format when there is no key to access value in Flutter?
[{"activityId":101,"docId":90,"status":1},{"activityId":101,"docId":100,"status":0},{"activityId":101,"docId":159,"status":0},{"activityId":101,"docId":201,"status":0},{"activityId":1784,"docId":123,"status":1}]
This looks like basic List<List<int>> so if data is [[101,4],[102,2],[103,1],[104,1],[105,1],[108,1],[109,1]] let's say you want to access number 4 from the start of the message you'd need to access it like:
final response = <List<int>> [[101,4],[102,2],[103,1],[104,1],[105,1],[108,1],[109,1]]
int four = response[0][1];
print('$four')
in terminal would print value 4

Bonita bmp 7 : bind JSON data to table

I'm a new in Bonita bpm. I receive data from my connector in the form as a json string.
There is like connector output param. I store this param like pool variable.
Then, i get this value with external api:
../API/bpm/activityVariable/{{taskId}}/response_rows[enter image description here][1]
I got json array like :
[{"reason":"reason","createdBy":"4","endDate":"2018-11-23T00:00:00+0000","persistenceId":"1","isApproved":"false","persistenceVersion":"0","startDate":"2018-11-15T00:00:00+0000","createtionDate":"2018-11-21T05:56:02+0000"},{"reason":"reason","createdBy":"4","endDate":"2018-11-23T00:00:00+0000","persistenceId":"2","isApproved":"false","persistenceVersion":"0","startDate":"2018-11-16T00:00:00+0000","createtionDate":"2018-11-21T06:01:26+0000"},{"reason":"test","createdBy":"4","endDate":"2018-11-16T00:00:00+0000","persistenceId":"3","isApproved":"false","persistenceVersion":"0","startDate":"2018-11-16T00:00:00+0000","createtionDate":"2018-11-21T07:26:57+0000"},{"reason":"reason","createdBy":"4","endDate":"2018-11-23T00:00:00+0000","persistenceId":"33","isApproved":"false","persistenceVersion":"0","startDate":"2018-11-22T00:00:00+0000","createtionDate":"2018-11-21T13:25:35+0000"},{"reason":"1111","createdBy":"4","endDate":"2018-11-17T00:00:00+0000","persistenceId":"34","isApproved":"false","persistenceVersion":"0","startDate":"2018-11-17T00:00:00+0000","createtionDate":"2018-11-21T13:26:58+0000"},{"reason":"rrr","createdBy":"4","endDate":"2018-11-30T00:00:00+0000","persistenceId":"35","isApproved":"false","persistenceVersion":"0","startDate":"2018-11-09T00:00:00+0000","createtionDate":"2018-11-21T13:29:37+0000"}]
I can create json variable from this json and set it as a data source.
I see that everything works fine. But when I set the data as External API variable nothing is displayed in the table.
I use the expression of my variable and not a constant (a small button in the content setting).
How can I show json array as a table ? Is it posiible ?
You can alternately save the API URL as a String Variable
return '../API/bpm/activityVariable/' + $data.taskId + '/response_rows[enter image description here][1]';
and use it as URL expression or variable.

How to query mongoDB using mongoose?

How do you query MongoDB using mongoose with node.js? I have it to where I can insert my JSON object to my DB, but all the ways I have tried to return the JSON object from the DB return null or just information about the database.
Is there some good method using mongoose to be able to query the database similar to the method:
var cursor = db.collection.find()
var JSONobject = cursor.next()
Here's what is in my code right now:
mongoose.connect('mongodb://localhost/myDB');
mongoose.connection.on('error', console.error.bind(console, 'connection error:'));
var cursor = mongoose.connection.db.contents.find();
console.log(cursor.next());
This throws an error at the line :
var cursor = mongoose....
claiming 'cannot call method 'find' of undefined'.
Note, that my collection 'contents' does in fact exist, and it contains one JSON document. I know this because I manually navigated to the collection using the mongo shell.
Edit: I am open to alternative methods to querying the database. I simply just want to be able to return JSON objects from my DB one at a time, while keeping track of where the client is at in the database.
One method to query mongoDB using mongoose is as follows:
Content.findOne().exec(function(err,docs){console.log(docs)});
Docs contains the JSON object. Access its attributes like any other object.
Note, this method uses asynchronous call backs. As such, you can't store the JSON object docs to a variable in order to use the JSON document information outside of the function. Therefore, you need to perform whatever actions needed with the JSON docs object information inside of the function.
For example, I was needing the query information to provide the filepath for my get api. As such, the result was as follows:
//get
app.get('/api/media/', function(req,res){
Content.findOne().exec(function(err,docs){res.sendFile(path.join(__dirname, '/api/media/', docs.filename))});
});
Note, Content is the model of my schema, and one of its parameters is filename.

In Talend, how do you keep input values provided to tSoap so that you can use them with the Soap response?

I have a Talend Job that currently does the following:
Input CSV --Main--> tMap --Output--> tSoap --Main--> Output CSV
The input CSV has
ID and TYPE as input columns.
The Map creates a Soap XML (String) message using the ID from the CSV and passes that String to the tSoap component.
The tSoap component fires the web request, which sends the response to the next component. That data is then written to CSV.
The problem is that TYPE from the input CSV is not passed through to amalgamate with the SOAP response data. Only the response data seems accessible.
I've had a look at tBufferInput / tBufferOutput and tFlowToIterate but they seem to work in scenarios where the tSoap component does not depend on an input from the main flow.
Does anyone know which components can be used to achieve the amalgamation?
Thank you
If you output the data you need to reuse to a tHashOutput component you should be able to rejoin your data with the response output from tSoap assuming there's some natural join element from the response.
I solved this in the end by:
Placing between the output from the tMap and the input to the tSoap, a new component - tSetGlobalVar
Inside tSetGlobalVar, you can then create a new row, which maps an input column (Value) to a named variable that you specify as the 'Key'.
E.g. Key = "ID", Value = row11.ID
The output from tSetGlobalVar then goes into the tSoap component.
The output from tSoap goes into a new tMap.
Inside this new tMap is the Body column from the previous tSoap component which maps to an output column. To access the stored "ID" variable for the current flow/iteration, I created a new output column, and instead of mapping any columns from the inputs, used (String)globalMap.get("ID"); which would insert the value back into the flow.

Filling dojo combobox with json data

I have a json object retrieved from a method which contains user information. I want to set that json object as a store of a dojo combobox. Please help.
So if I understand correctly, you want to use a single object as the store of a combobox (so it would only give 1 option?). If you're trying to use an array of JSON objects as a JSON store, I suggest looking at enter link description here.
As you can see they have a store with inside the data attribute an array of JSON objects.
new Memory({
data: [
...
]
});
Then they create a ComboBox and the most important things are the store and the searchAttr properties. With the store property you can connect your store to the combobox and with the searchAttr property you can say which property of your JSON object is the visible thing that should be displayed in your combobox.