1

POSTing a JSON matrix on Node destroys the structure

 2 years ago
source link: https://www.codesd.com/item/posting-a-json-matrix-on-node-destroys-the-structure.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

POSTing a JSON matrix on Node destroys the structure

advertisements

The JSON object that I am POSTing is losing its array structure when it hits the Node JS body-parser.

I am Posting a JSON object with the following structure:

{

FirstName: "Name",
LastName: "Name",

Cars: [

  {

     Make: "Ford",
     Model: "Mustang"

  }

]

However when the Node JS backend calls req.body object I get:

{
"FirstName":"Name",
"LastName":"Name",
"Cars[0][Make]":"Ford",
"Cars[0][Model]":"Mustang"
}

Any reason this does not come over as a JSON with a array of objects that I can parse?


Had something similar today sendign with JSON.stringify sorted it out

Related Articles

Are JSON diagrams necessary to define the structure of a JSON?

I am asking this because I see that the current JSON schema draft (http://json-schema.org/) proposes to have the schema of JSON in the following way: for the JSON : { "a":"abc" "b": 123 } the schema proposed in the draft is l

Finding nodes in the structure of the SQL tree

I have a tree-like data model stored in a MYSQL database. The tree is traversed by using two fields on each 'node' object: id parent_id The root id has a parent_id of 'null' and all other nodes in the tree reference a parent id. If I want to get a li

Removes certain elements from the numpy array without destroying the structure

I have a numpy array as below, I want to remove all zeros. a = [[ 5 2 0 9 4] [ 2 0 9 4 2] [ 0 9 4 2 6] [ 9 4 2 6 8] [ 4 2 6 8 0] [ 2 6 8 0 3] [ 6 8 0 3 11] [ 8 0 3 11 7] [ 0 3 11 7 1] [ 3 11 7 1 5] [11 7 1 5 21] [ 7 1 5 21 8] [ 1 5 21 8 0] [ 5 21 8 0

edit something in a list & ldquo; of tuples lists & rdquo; structure without destroying the structure in python

It sounds like a simple question. But, given a: a = [[(1,2)], [(3,4), (5,6)], [(7,8), (9,10), (11,12)]] How can I add 1 to each of the first item in the tuples, so that I get the follwing? b = [[(2,2)], [(4,4), (6,6), [(8,8), (10,10), (12,12)]] I tri

How can I reduce a html template file without destroying the structure?

I have a handlebars template file that I'd like to minify. I found a couple questions that were related to my issue on StackOverflow, but nothing exactly like it that had an answer. My issue is that spaces that are within the templated values are get

Manipulating the end point json data before moving to the display using express

I am currently working on an express site that grabs content and data from various webservice calls. The site's navigation data used for rendering the site mega menu is coming from an endpoint that sends a nested json result set that contains the str

Adding an xml node to the top of the file or reversing the loop

I am using xml. Reading the xml-document works fine, adding nodes works fine to but I want the node to add on top of the xml file. Is this possible or is this a nogo? The reason I want this is because when I display the xml file I want the last added

ExtJS: Destroy the window with the 'closeAction' config set to 'hide'

I have a window with closeAction configured to 'hide' on instantiation: var myWin = Ext.create('Ext.window.Window', { ... closeAction:'hide', ... }); Calling close() on myWin therefore simply hides the window. I need to destroy the window in the sens

ajax POST a JSON array to the nodejs server deletes the keys

RESOLVED! see solution at bottom of this post...I have been stuck on this problem for about 2 days now and it's starting to get to me. I am trying to POST a Json array to my node server (cross-domain) and insert it to a cloudant db. This question is

The most recent way to send HTTP POST with JSON payload in Grails

I know how to send an HTTP POST with JSON payload using Apache HTTP library or other conventional java ways. But is there a groovier or in fact grooviest way to do so in grails? I want a simplistic solution with minimum lines of code(=beauty of groov

JavaScript / jQuery to download the file via POST with JSON data

I have a jquery-based single-page webapp. It communicates with a RESTful web service via AJAX calls. I'm trying to accomplish the following: Submit a POST that contains JSON data to a REST url. If the request specifies a JSON response, then JSON is r

Sending the JSON Matrix to the Google Sheet Script Web Service

We have a webservice that returns product information. The service expects a JSON array in the post data... The A sample script from a simple HTML test web page is as follows (this works as expected): &ltscript src="//code.jquery.com/jquery-1.11.

Dojo - destroying the tooltip widget when the DOM node is destroyed

I use dijit/tooltips on a page that has a lot of domConstuct.destroy() and domConstuct.place() going on. So each time I remove some nodes from the DOM, I want to remove tooltips attached to those nodes. Currently the number of tooltip widgets is cons

Sending the post with json using a spray?

Sorry I can't manage to make this work: I need to add some json to a post, so following the documentation: http://spray.io/documentation/1.1-M8/spray-httpx/request-building/ : import scala.util.{Success, Failure} import akka.actor.{Props, ActorSystem

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK