JSON string inside a string-type in AWS model

My goal is to create a basic model that can accept a JSON string instead of defining all variables/elements upfront. The model will have an "options" element which will hold a JSON string. Below is the structure of my model.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "GroceryStoreInputModel",
  "type": "object",
  "properties": {
    "options":{"type":"string"}
  }
}

In my api-gateway, I found that it works if I provide a simple body like this:

{"options":"this is my options"}

However, I encountered a model not matching error when I replaced the string with a json string like this:

{"options":"{\"name\":\"thaison\",\"mail\":\"test2\"}"}

I also attempted to escape double quotes but it did not solve the issue. Is there a better way to approach this?

{"options":"{\"name\":\"thaison\",\"mail\":\"test2\"}"}

Answer №1

It seems like the payload value for the options node is being interpreted as an object instead of a string. Have you considered adjusting the settings below to resolve this issue?

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "GroceryStoreInputModel",
  "type": "object",
  "properties": {
    "options":{"type":"object"}
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Converting any given String into proper JSON format using JAVA

I am encountering an issue with parsing a String in a specific format using the Jackson ObjectMapper readTree API. Here is the code snippet I am using for parsing: ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(JsonParser.Feature.A ...

Participating in a scheduled Discord Voice chat session

Currently, I am in the process of developing a bot that is designed to automatically join a voice chat at midnight and play a specific song. I have experimented with the following code snippet: // To make use of the discord.js module const Discord = requ ...

Retrieve the body's coordinates when dragging an element using the jQuery UI library

How can I obtain the coordinates of a dragged div upon drag and drop action, including left, right, and top positions? Additionally, how do I then use Ajax to post these coordinates? An example link can be found at jsfiddle.net/qPw92 <html> &l ...

Error: The method of promise.then is not recognized as a function

Having an issue with Rxjs v5 while attempting to run http.get requests one after the other in sequential order. The error message received is TypeError: promise.then is not a function. Below is the code snippet in question: var http = require('ht ...

Breaking down arrays using the JADE Template Engine

Currently, I am utilizing the JADE template engine in conjunction with ExpressJS. I am attempting to pass an array to my JADE template like so: var data = { "labels" : ["Label 1", "Label 2"] }; res.render('index', {data: data}); The struct ...

When you access the `selectedIndex` property in JavaScript, it will return an object of type `HTMLSelect

I am currently working on a piece of code that retrieves the value from dropdown list items and then displays it in the document. To proceed, please select a fruit and click the button: <select id="mySelect"> <option>Apple</option ...

Tips for accessing the @keyframes selector and extracting the value from it

In my CSS code, I have a shape element with an animation that spins infinitely for 50 seconds. #shape { -webkit-animation: spin 50s infinite linear; } @-webkit-keyframes spin { 0% { transform: rotateY(0); } 100% { transform: rotateY(-360deg ...

Is it possible to directly add a child in HTML from nodejs?

I'm in the process of developing a chat application that requires users to select a room from a list of available rooms stored in <datalist> options, which are fetched from a SQL table on the server. Within my login.html file, users are prompte ...

javascript change string into an array of objects

let dataString = "{lat: -31.563910, lng: 147.154312};{lat: -33.718234, lng: 150.363181};{lat: -33.727111, lng: 150.371124}"; let dataArray = dataString.split(';'); Produces the following output: let dataArray = [ "{lat: -31.563910, lng: 147 ...

Error with Google Maps Display

My goal is to achieve two things with the code snippet below: If the geocode process is unsuccessful, I want to prevent the map from being displayed (currently, I've only hidden the error message). If the geocode process is successful, I only want t ...

Steps for sorting items from a list within the past 12 hours

I'm currently working with Angular and I have data in JSON format. My goal is to filter out items from the last 12 hours based on the "LastSeen" field of the data starting from the current date and time. This is a snippet of my data: { "Prod ...

Fetching data from a ColdFusion component using AJAX

Having trouble performing an SQL COUNT on my database using AJAX through a cfc file, and I can't figure out how to retrieve the return variable. Here's the relevant section of the cfc file: <cffunction name="getSpeakerCount" access="remote" r ...

Encountering difficulties in sending image data to server using Retrofit

Currently, I am facing challenges in sending an image to the server through retrofit. While the server can receive what I send, there seems to be an issue when I test it with Postman, as it displays something unexpected. Let me walk you through my data fir ...

Is it possible for Typescript to resolve a json file?

Is it possible to import a JSON file without specifying the extension in typescript? For instance, if I have a file named file.json, and this is my TypeScript code: import jsonData from './file'. However, I am encountering an error: [ts] Cannot ...

`Error encountered while parsing JSON data in Python`

Having trouble parsing this JSON in Python '''[{"accountName":"London\"Paris\"Geneva","accountId":"1664800781","isActive":true,"timeZone":"Asia/Jerusalem","currency":"ILS"}]''' This results in the following error m ...

Steps for eliminating the chat value from an array tab in React

tabs: [ '/home', '/about', '/chat' ]; <ResponsiveNav ppearance="subtle" justified removable moreText={<Icon icon="more" />} moreProps={{ noCar ...

Retrieve all the records from the collection that have a specific reference number in their ID field

Is it feasible to pull together all documents with an ID that includes a specific value? I am working with Angular 7. I attempted using db.collection('items').where.. but unfortunately, this method is not supported. For instance: (collection) ...

Extract specific information from Ansible Output

Looking to extract hostnames from the output obtained after running a specific playbook. The relevant output is shown below. ok: [localhost] => msg: changed: false clusters: RDG1-DC-2: datacenter: RDG1 drs_default_vm_beha ...

The function estimatedDocumentCount() actually returns an object rather than a numerical value

I am currently working on a feature in my web application where I want to display the number of documents stored in my MongoDB database whenever a user visits the homepage. To achieve this, I have outlined the implementation process in the following diagra ...

Tips for retrieving the posted object in angularJS

My current challenge involves creating an object with a defined name, posting it into a database, and then immediately finding its position and obtaining its id. However, I have noticed that using "get" right after "post" retrieves the data before it' ...