Extract and reorder JSON Data

Forgive me as I should be able to figure this out but cannot :slight_smile:

I’m trying to:

  1. extract specific key:value pairs from JSON
  2. rearrange the order
  3. rename the keys

So given something like:

[
  { 
    title: "Angels & Demons",
    author: "Dan Brown",
    isbn: "9781416524793",
    genres: ["Fiction"]
  },
  {
    title: "The Da Vinci Code",
    author: "Dan Brown",
    isbn: "9780307879257",
    genres: ["Fiction"]
  }
]

I’d like to transform the above to only include isbn and title, change their order, and change the key name.

[
  { 
     Code: "9781416524793",    
     Book: "Angels & Demons",
  },
  {
     Code: "9780307879257",    
     Book: "The Da Vinci Code",
  }
]

hi @blschaef15,

If the JSON object is called transform then you could do:

FROM item IN transform SELECT { "Code": item.isbn, "Book": item.title }


1 Like

Worked perfectly, thank you!