문제

I want to do a serialize the data that I got from 3rd Party API. The following Picture is what I got from the API

data received from Ink Filepicker API

As you can see in the photo, I have received 2 sets of the Information which indicated by the number in the []. And when I do the POST request using jQuery, the multiple Parameters Posts to my Java method. What I would like to do is to encapsulate each set ot the Information into a Group and after that serialize them in one parameter and sent it back as one object that hold all the things inside. How can I do it by Javascrip or jQuery???

anyway, this is my code

function getMediaInfo(InkBlob){

console.log(InkBlob);

jQuery.ajax({
  type: 'POST',
  url: '/webapp/filepicker/importAssets',
  dataType: 'json',
  data: {"inkBlob": InkBlob}
  }); }

All I want to do is to set only one parameter call inkBlob that contains the Information as Show in the photo above.

도움이 되었습니까?

해결책

How about -

For Serializing js object
var str = JSON.stringify(InkBlob);

jQuery.ajax({
  type: 'POST',
  url: '/webapp/filepicker/importAssets',
  dataType: 'json',
  data: {"inkBlob": str}
  }); 

Note

JSON.stringify is not available for older browser, use JSON2.js for older browsers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top