What is the parenthesis in a json? [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
An API call returns a json looking like below:
{
"applicationData": {
"outerMap": {
"record(id=1, description=description)": {
"key(id=1, englishDescription=enDescription)": [
{
"id": 1,
"description": "point 1"
},
{
"id": 2,
"description": "point 2"
}
]
}
}
},
"messages": [
"successfully"
],
"httpStatus": "OK"
}
The return type of the API call is:
public class Data {
private Map<Record, Map<Key, List<Point>>> outerMap;
}
I don't remember parenthesis is used in json, so quite confused about it. Seesm it could be used to "de-serialize" to restore the object?

Every valid string can be a valid key in JSON. So parentheses in key names are possible.
It is up to the application to interpret the content of the parentheses.

Related

Create JSON with wrapped name in javascript? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
For example i have JSON like this
{
"1":"12",
"2":"13",
"3":"14"
}
How can i wrap them like
"data":{
"1":"12",
"2":"13",
"3":"14"
}
Any lib we can do this ?
Thank you a lots
const json = `{
"1": "34.4",
"dog":"Snoopy",
"more": [ 1, 2, 3, 4 ]
}`
const myObj = {
data: JSON.parse(json)
}
console.log(myObj);
Simply that would do it. JSON is simply a string format, representing a javascript object. So within myObj, I can assign that to an object property and parse that JSON string into an object.

How to loop over a nested JavaScript object in jQuery? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am new to Javascript and jQuery. I am trying to create something like this (object) below and read the keys and retrieve the values.
var members = {unit:1,name: ["AA", "AB"],userid:["0001","0002"],
{unit:2,name: ["BA", "BB"],userid:["0011","0012"]};
if 'Unit' == 1 then display name array.
Basically I want loop through the object and retrieve the value.
I think you member should be like this
var members = [{unit:1,name: ["AA", "AB"],userid:["0001","0002"]},
{unit:2,name: ["BA", "BB"],userid:["0011","0012"]}];
var members = [{unit:1,name: ["AA", "AB"],userid:["0001","0002"]},
{unit:2,name: ["BA", "BB"],userid:["0011","0012"]}];
members.forEach(function(v,i){
if(v.unit==1)
{
console.log(v.name);
}
});
I guess this is want you wanted, an object within an object. Where 'unit' is the key for retrieving the objects within the object.
var members = {
1: {
name: ["test","test"],
userid: ["0001","0002"]},
2: {
name: ["test2", "test2"],
userid: ["0011", "0012"]}
};
console.log(members[1]);

Liferay - Set Expando Field Value in a Javascript Function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I need to set a User Expando field value in a Javascript Function in liferay. It is possible to do?
You can use the json api like this way
Liferay.Service(
'/expandovalue/add-value',
{
companyId: 20154,
className: 'com.liferay.portal.model.User',
tableName: 'CUSTOM_FIELDS',
columnName: 'test',
classPK: 30924,
data: 'test'
},
function(obj) {
console.log(obj);
}
);
where
columnName is the name of your custom field
classPK is the entity id in this case userId
data the value of the custom field

AngularJS - How create a form with specific format? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm newbie in AngularJS and I'm working on ACTIVITI.
I need to create a form in a specific format. Every response must be in the form of:
{
"taskId" : "5",
"properties" : [
{
"id" : "room",
"value" : "normal"
}
]
}
The user input some text in the form, and the attribute "value" need to be equal to the user input.
How to reach this in AngularJS?
you bind your input with the ng-model directive to your value:
controller:
$scope.toto = {
"taskId" : "5",
"properties" : [
{
"id" : "room",
"value" : "normal"
}
]
}
.html:
<input ng-model="toto.properties[0].value">
I think you want this:
<input ng-model="formInfo.taskId">
<input ng-model="formInfo.properties.id">
<input ng-model="formInfo.properties.value">
controller:
console.log($scope.formInfo.taskId);
console.log($scope.formInfo.properties.id);
console.log($scope.formInfo.properties.value);

Arrays inside objects [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to create an object that inside him have some fields, one of them supposed to be an array.
var ob=
{
name : "asdad"
array ?
}
But I dont know how to.
Can anyone help me?
Thank you!
a value is just a value, whether it be a simple scalar or a complicated looking object.
var obj = {
name: "user name",
stocks: ["AAPL", "GOOG"],
cars: [ {make:"Honda", model: "accord"},
{make:"BMW", model: "525", year: 2014}
]
};
do something like this:
var ob= {
name : "asdad",
myArray : ["value1", "value2", "etc."]
}
It would be helpful for you to go over this MDN doc.

Categories