-Hi, i am new to Couchbase and trying to retrieve certain portions of my JSON data which have been stored successfully into my document but to no avail. i always get a null value.
-I retrieve the properties for project_id, project_name and forms using
the document.getProperty("") method;
-But I always get “null” when i try to retrieve any other data (eg. form_name, variables) using
the document.getProperty("") method. Please help ASAP
This is my JSON data being stored after being converted into hashmap using_**HashMap<String,Object> properties = new Gson().fromJson(jsonString, new TypeToken<HashMap<String, Object>>(){}.getType()).**
{
"project_id": "PROJ10001",
"project_name":"Sample Project",
"forms": [
{
"form_name": "main",
"form_id": "FORM001",
"variables": [
{
"id":"VAR0001",
"variable_name": "firstname",
"variable_label": "First Name",
"input_type": "text",
"hidden_text": "",
"required": "1",
"options": {},
"default_value": "n/a",
"max_length": 50,
"min_length": 2,
"pre_condition": "",
"post_condition": "",
"order_in_form": "1"
},
{
"id":"VAR0002",
"variable_name": "age",
"variable_label": "What is your current age",
"input_type": "number",
"hidden_text": "",
"required": "1",
"options": {},
"default_value": "0",
"max_length": 3,
"min_length": 2,
"pre_condition": "",
"post_condition": "",
"order_in_form": "2"
},
{
"id":"VAR0003",
"variable_name": "gender",
"variable_label": "Gender",
"input_type": "options",
"hidden_text": "",
"required": "1",
"options": {
"type":"list",
"multi":"0",
"items":[
{"label":"Male","value":"m", "skip":""},
{"label":"Female","value":"f", "skip":""}
]
},
"default_value": "0",
"max_length": 3,
"min_length": 2,
"pre_condition": "",
"post_condition": "",
"order_in_form": "3"
}]
},
{
"form_name": "male_form",
"form_id": "FORM002",
"variables":
[
{
"id":"VAR0004",
"variable_name": "beard",
"variable_label": "How many shirts do you have?",
"input_type": "number",
"hidden_text": "",
"required": "1",
"options": {},
"default_value": "n/a",
"max_length": 3,
"min_length": 2,
"pre_condition": "",
"post_condition": "",
"order_in_form": "1"
}
]
}
]
}