how do I save data structure which content object, array and nested array into Baas?

Not applicable

Hello,

I am trying to save whole data structure to Baas. My data structure is combination of object, array and nested array. It looks like this below:

var abc= {

keys:{

key1:{

name: "dhwani",

type: string,

default:true/false,

value: "trivedi"

},

key2:{

name: "age",

type: number,

default:true/false,

value: 10

}

},

myArray: [{

index: "name",

name: "abcdef",

value: null,

type: string,

default: true/false

},{

index: "name",

name: "pqrst",

value: "black",

type: string,

default: true/false

}],

myArrayInNewArray: [{

index: "name",

name: "abcdef",

value: null,

type: string,

default: true/false

},{

index: "name",

name: "abcdef",

type: array,

default: true/false,

value: newArray[{

index: "name",

name: "abcdef",

type: array,

default: true/false,

value: insideNewArray [{

type: 12345,

value:"test.com",

type: string

}]

}]

}]

}

I am getting confused that does Baas is capable to store or not? If yes then how?

Thank you.

Regards,

Dhwani.

Solved Solved
0 6 395
1 ACCEPTED SOLUTION

sarthak
Participant V

You can store any json object in BaaS. A json object can contain arrays and complex objects.

The keys should be string for it to be json. So your initial elements will look like :

{
	"keys": {
		"key1": {
			"name": "dhwani",

and use this online tool : http://jsonlint.com/ to validate the json.

A json array is structured as follows:

"employees":[   

 {"firstName":"John", "lastName":"Doe"},     

{"firstName":"Anna", "lastName":"Smith"},     

{"firstName":"Peter","lastName":"Jones"}

]

See further examples here: http://json.org/example.html

View solution in original post

6 REPLIES 6

sarthak
Participant V

You can store any json object in BaaS. A json object can contain arrays and complex objects.

The keys should be string for it to be json. So your initial elements will look like :

{
	"keys": {
		"key1": {
			"name": "dhwani",

and use this online tool : http://jsonlint.com/ to validate the json.

A json array is structured as follows:

"employees":[   

 {"firstName":"John", "lastName":"Doe"},     

{"firstName":"Anna", "lastName":"Smith"},     

{"firstName":"Peter","lastName":"Jones"}

]

See further examples here: http://json.org/example.html

Thank you @sarthak to answer me quickly. But, one more thing to ask: I learn that it save object but what about array and nested array? If it save that to then do you have any example for that?

By the way your previous answer is so helpful. Thank you. 🙂

Tip: best to show gratitude is to upvote the answer and accept if it answered your question. Smart people believe in karma and karma points 😉

Thank you @Birute Awash. That is good suggestion. will do. 🙂

@Dhwani Trivedi I updated my initial answer to answer your question. Please let me know if this helps.

Thank you @sarthak 🙂 . This is really helpful. Thank you. 🙂