Ask Your Question
0

Add a new field in between the json

asked 2020-06-02 02:18:06 -0500

anonymous user

Anonymous

updated 2020-06-09 00:54:34 -0500

iamontheinet gravatar image

Hi I want to add a new field in between the json. like below.

my action is as below. /university/college_names[0]/ /university/college_names[1]/

{"university":
{
"college_names":[
          { "name_a": {
                   "frts_name": "asasa"
                    "second_name": "bdbdb"}}
           {"name_b":{
                   "frts_name": "bdbii"
                   "second_name": "upespe"}}
]          
}
}

i want to convert it into. Output should be as below mentioned json document /university/college_names[0]/col_id/ /university/college_names[1]/col_id/

{"university":
{
"college_names":[
          {"col_id":
                 { "name_a": {
                             "frts_name": "asasa"
                              "second_name": "bdbdb"}}
          }

           {"col_id":
                  {"name_b":{
                             "frts_name": "bdbii"
                             "second_name": "upespe"}}
           }
]          
}
}
edit retag flag offensive close merge delete

Comments

Did you change your original question? My answer below corresponds to your original question. Hopefully you get the idea.

iamontheinet gravatar imageiamontheinet ( 2020-06-09 00:55:54 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-09 00:53:30 -0500

iamontheinet gravatar image

Hi!

Here's a way to accomplish what you're trying to do. Expression Evaluator should contain the following expressions:

[
    {
        "fieldToSet": "/university/city",
        "expression": "${emptyMap()}"
    },
    {
        "fieldToSet": "/university/city/college",
        "expression": "${emptyList()}"
    },
    {
        "fieldToSet": "/university/city/college",
        "expression": "${record:value('/university/college_names')}"
    }
]

Then, use Field Remover to remove the original /university/college_names field.

Here are some visuals.

image description


image description


image description

Hope this helps.

Cheers, Dash

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-06-02 02:18:06 -0500

Seen: 20 times

Last updated: Jun 09