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);
Related
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.
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.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I am trying to parse a JSON string. It says 'Unexpected token ] in JSON at position 361'. I have the feeling I just overlooked something silly.
{
"username": "bob",
"user_found": "time",
"meta": [
{
"name" : [
{
"hash" : [
{
"content" : "con1",
"cont2" : "con2",
"date" : "time"
},
],
},
],
},
],
}
Figured it out, commas are invalid. Even for an expanding mono structure.
The reason is because of the unwanted comma at the end of each of the object and array.
The error message is saying it does not expect the bracket due to the commas saying there's going to be another item in the objects or arrays.
Remove the commas at the end of the list items:
{
"username": "bob",
"user_found": "time",
"meta": [
{
"name" : [
{
"hash" : [
{
"content" : "con1",
"cont2" : "con2",
"date" : "time"
}
]
}
]
}
]
}
Try entering it in a json validator to check that it's valid, e.g.: https://jsonlint.com/
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
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.