Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Problem Statement

Possible SolutionsSub-TasksNotes/CommentsPros/Cons

Add support for JSON data with multiple top level nodes. Refer:

Jira
serverONAP Jira
serverId425b2b0a-557c-3c0c-b515-579789cceedb
keyCPS-341

Identify the top-level data nodes in the existing JSON payload and then iterate over them and store them individually one by one in using Create node endpoint
  • Make a separate PoC where we parse JSON data individually
  • Get operation needs to be updated accordingly, currently it returns only the first data tree even if multiple data trees exist under same anchor. New Get Data node API is needed
  • Gson gson might have support for this, Need more research on it
  • CPS team preferred Jackson over gson

Pros: 

  • No changes to current payload
  • No need to write new API, existing API will serve the purpose
  • Backwards compatible

Cons:

  • The approach is complex compared to using JSON array as payload, Need to write logic to parse over multiple data tree without losing top key element and this might require additional libraries as well.
Use JSON array and store the JSON array in CPS DB using Create node endpoint 
  • need to define new payload

Sample:

Code Block
[{...},{...},{...}]
  • New test cases need to be added
  • Need to update get operation as well to retrieve multiple data trees, so new endpoint is needed
  • Need to test existing GET nodes API in depth.
  • The payload needs to be changed. Will add the payload format soon.
  • Need to identify which endpoints might get effected with this change
  • Can convert the JSON object payload to an Array internally when single object is passed

Pros:

  • Minimal code change (approach will require us to iterate over multiple data trees passed as JSON array)

Cons:

  • New endpoint need to be added. Need to decide on endpoint because current Post API uses "nodes".

...

Possible SolutionsPayloadDescription/FindingsComments
Identify the top-level keys in the existing JSON payload (which is JSON object) and then iterate over them and store them individually one by one in using Create node endpoint

The JSON object with multiple data trees would be structured as follows:

Code Block
{
  "top_key_of_data_tree_container-1": { values },   //data tree 1
  "top_key_of_data_tree_container-2": { values }    //data tree 2
}

Refer the following files for Yang and Json data (from spike CPS-341):

View file
nameJSON-object-multiple-top.json
height150
View file
nameJSON-object-multiple-top.yang
height150

  • Generally to iterate over a JSON object the top level key (here top_key_of_data_tree_1 and top_key_of_data_tree_2) is used to identify the number of data trees in the JSON object.
  • The problem with this approach is, that the libraries tested for the usecase only return the values stored under the top key and in order to retain the whole JSON we need to perform some data manipulation (concatenating key with value within CPS) which is not feasible.

Use new payload in form of JSON array and store the JSON array in CPS DB using Create node endpoint 

The JSON object with multiple data trees would be structured as follows:

Code Block
[
	{   //data tree 1
    	"top_key_of_data_tree_container-1": { values }
	},
	{   //data tree 2
    	"top_key_of_data_tree_1container-2": { values }
	}
]

Refer the following files for Yang and Json data (from spike CPS-341):

View file
nameJSON-array-multiple-data-tree.json
height150
View file
nameJSON-array-multiple-data-tree.yang
height150

  • In this approach the data is received as JSON array and by performing simple iteration over the array we should be able to store the data with multiple trees in CPS
  • A PoC is WIP for the same.

...