ali haider
ali haider

Reputation: 20182

correct way to represent data in JSON

I have the following bit of information used as key representation for data where the key is meant to be dynamic i.e. not hardcoded as FB and SB - it could be AB, CD, EF in another instance (i.e. neither the number of keys nor their names are static). The initial version I have is as follows:

{"FB":"psOVGY55Rnkr3QHntSCQ==","SB":"oOUaYrIxAVixf5zfslGwvcy44g=="}

I think it needs to be something like this:

 [{"name: "FB", "value": "psOVGY55Rnkr3QHntSCQ==",}]

I would appreciate feedback (would be great if any down/close voters can answer the question in addition to close/down voting). Thanks

Update

The reason I am inquiring is because currently, the "key" being passed is dynamic, not static so I cannot create a POJO with attributes FB, SB since these values will change per message.

Upvotes: 0

Views: 196

Answers (1)

M Pankaj Arun
M Pankaj Arun

Reputation: 86

I got your question a little bit. It is the data format formed by arranging string values with special characters like, { }, [ ], ‘,’, ‘:’. Arranging strings with these characters makes entire data meaningful. A String contains a collection of data and data inside JSON represented as name-value pairs.

Have a look at the below simple JSON string that represents information of keys.

“keys”   :[{
                “name” : “FB”,
                “number” : “psOVGY55Rnkr3QHntSCQ==”
                   },
               {
                “name” : “SB”,
                “number” : “”
               }] 

Upvotes: 1

Related Questions