$.param serialized object to JSON
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I send data from client to server (Python) using $.fileDownload. API receives the data but, as the jQuery fileDownload docs state, the data is serialiazed using $.param. The problem is that I need to have the data in JSON format so that I can handle it and create a file using it's key:value pairs. I've been trying to figure this out but nothing seems to be done in order to "deserialize" it. It also seems that I can't make $.fileDownload to send data as a JSON object in the first place. Is there any way that I turn the serialized data to JSON?
Here is my JavaScript request:
let data =
'name': item.Name,
'rows': item.rows
window.$.fileDownload('/api/export-report-excel',
httpMethod: 'POST',
encodeHTMLEntities: true,
data: data
)
In my API I've tried json methods (json.dumps etc.) but the serialized object cannot be converted.
The $.fileDownload states:
// data must be an object (which will be $.param serialized) or already a key=value param string
EDIT:
In my Falcon API:
@route('/api/export-report-excel')
class ExportReportToExcel(object):
def on_post(self, req, resp):
data = req.stream.read()
log.info(data)
log.info(data) output:
b'name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2'
javascript python jquery json serialization
add a comment |
I send data from client to server (Python) using $.fileDownload. API receives the data but, as the jQuery fileDownload docs state, the data is serialiazed using $.param. The problem is that I need to have the data in JSON format so that I can handle it and create a file using it's key:value pairs. I've been trying to figure this out but nothing seems to be done in order to "deserialize" it. It also seems that I can't make $.fileDownload to send data as a JSON object in the first place. Is there any way that I turn the serialized data to JSON?
Here is my JavaScript request:
let data =
'name': item.Name,
'rows': item.rows
window.$.fileDownload('/api/export-report-excel',
httpMethod: 'POST',
encodeHTMLEntities: true,
data: data
)
In my API I've tried json methods (json.dumps etc.) but the serialized object cannot be converted.
The $.fileDownload states:
// data must be an object (which will be $.param serialized) or already a key=value param string
EDIT:
In my Falcon API:
@route('/api/export-report-excel')
class ExportReportToExcel(object):
def on_post(self, req, resp):
data = req.stream.read()
log.info(data)
log.info(data) output:
b'name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2'
javascript python jquery json serialization
You haven't really explained enough about what you are doing. What is handling this request? Your server is not just "Python", presumably it's running some kind of framework - which? You need to show the server-side code and what you tried to decode this parameters.
– Daniel Roseman
Nov 16 '18 at 12:47
It's running falcon to handle the request. As I mentioned, I tried json.(methods) but it doesn't work. The problem is that the data is serialized through $.param and then sent over the the server.
– Fotis Papadamis
Nov 16 '18 at 12:51
No that is not the problem. But you need to show your Falcon code. What did you try to pass to the json method? And do you actually need a JSON string, or a dict? What are you hoping to do with the data?
– Daniel Roseman
Nov 16 '18 at 12:57
I tried both dumps and loads. I'm reading the data using req.stream.read(). That's what I tried to pass in dumps and loads. I didn't post my Falcon code because I keep changing it all the time, I can't manage to get the data to be converted in json.
– Fotis Papadamis
Nov 16 '18 at 13:01
@DanielRoseman posted what I get in my API. I tried to deserialize it with pickle but it didn't work. I can't find a way to convert it back to an object.
– Fotis Papadamis
Nov 16 '18 at 14:14
add a comment |
I send data from client to server (Python) using $.fileDownload. API receives the data but, as the jQuery fileDownload docs state, the data is serialiazed using $.param. The problem is that I need to have the data in JSON format so that I can handle it and create a file using it's key:value pairs. I've been trying to figure this out but nothing seems to be done in order to "deserialize" it. It also seems that I can't make $.fileDownload to send data as a JSON object in the first place. Is there any way that I turn the serialized data to JSON?
Here is my JavaScript request:
let data =
'name': item.Name,
'rows': item.rows
window.$.fileDownload('/api/export-report-excel',
httpMethod: 'POST',
encodeHTMLEntities: true,
data: data
)
In my API I've tried json methods (json.dumps etc.) but the serialized object cannot be converted.
The $.fileDownload states:
// data must be an object (which will be $.param serialized) or already a key=value param string
EDIT:
In my Falcon API:
@route('/api/export-report-excel')
class ExportReportToExcel(object):
def on_post(self, req, resp):
data = req.stream.read()
log.info(data)
log.info(data) output:
b'name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2'
javascript python jquery json serialization
I send data from client to server (Python) using $.fileDownload. API receives the data but, as the jQuery fileDownload docs state, the data is serialiazed using $.param. The problem is that I need to have the data in JSON format so that I can handle it and create a file using it's key:value pairs. I've been trying to figure this out but nothing seems to be done in order to "deserialize" it. It also seems that I can't make $.fileDownload to send data as a JSON object in the first place. Is there any way that I turn the serialized data to JSON?
Here is my JavaScript request:
let data =
'name': item.Name,
'rows': item.rows
window.$.fileDownload('/api/export-report-excel',
httpMethod: 'POST',
encodeHTMLEntities: true,
data: data
)
In my API I've tried json methods (json.dumps etc.) but the serialized object cannot be converted.
The $.fileDownload states:
// data must be an object (which will be $.param serialized) or already a key=value param string
EDIT:
In my Falcon API:
@route('/api/export-report-excel')
class ExportReportToExcel(object):
def on_post(self, req, resp):
data = req.stream.read()
log.info(data)
log.info(data) output:
b'name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2'
javascript python jquery json serialization
javascript python jquery json serialization
edited Nov 16 '18 at 14:12
Fotis Papadamis
asked Nov 16 '18 at 12:35
Fotis PapadamisFotis Papadamis
577
577
You haven't really explained enough about what you are doing. What is handling this request? Your server is not just "Python", presumably it's running some kind of framework - which? You need to show the server-side code and what you tried to decode this parameters.
– Daniel Roseman
Nov 16 '18 at 12:47
It's running falcon to handle the request. As I mentioned, I tried json.(methods) but it doesn't work. The problem is that the data is serialized through $.param and then sent over the the server.
– Fotis Papadamis
Nov 16 '18 at 12:51
No that is not the problem. But you need to show your Falcon code. What did you try to pass to the json method? And do you actually need a JSON string, or a dict? What are you hoping to do with the data?
– Daniel Roseman
Nov 16 '18 at 12:57
I tried both dumps and loads. I'm reading the data using req.stream.read(). That's what I tried to pass in dumps and loads. I didn't post my Falcon code because I keep changing it all the time, I can't manage to get the data to be converted in json.
– Fotis Papadamis
Nov 16 '18 at 13:01
@DanielRoseman posted what I get in my API. I tried to deserialize it with pickle but it didn't work. I can't find a way to convert it back to an object.
– Fotis Papadamis
Nov 16 '18 at 14:14
add a comment |
You haven't really explained enough about what you are doing. What is handling this request? Your server is not just "Python", presumably it's running some kind of framework - which? You need to show the server-side code and what you tried to decode this parameters.
– Daniel Roseman
Nov 16 '18 at 12:47
It's running falcon to handle the request. As I mentioned, I tried json.(methods) but it doesn't work. The problem is that the data is serialized through $.param and then sent over the the server.
– Fotis Papadamis
Nov 16 '18 at 12:51
No that is not the problem. But you need to show your Falcon code. What did you try to pass to the json method? And do you actually need a JSON string, or a dict? What are you hoping to do with the data?
– Daniel Roseman
Nov 16 '18 at 12:57
I tried both dumps and loads. I'm reading the data using req.stream.read(). That's what I tried to pass in dumps and loads. I didn't post my Falcon code because I keep changing it all the time, I can't manage to get the data to be converted in json.
– Fotis Papadamis
Nov 16 '18 at 13:01
@DanielRoseman posted what I get in my API. I tried to deserialize it with pickle but it didn't work. I can't find a way to convert it back to an object.
– Fotis Papadamis
Nov 16 '18 at 14:14
You haven't really explained enough about what you are doing. What is handling this request? Your server is not just "Python", presumably it's running some kind of framework - which? You need to show the server-side code and what you tried to decode this parameters.
– Daniel Roseman
Nov 16 '18 at 12:47
You haven't really explained enough about what you are doing. What is handling this request? Your server is not just "Python", presumably it's running some kind of framework - which? You need to show the server-side code and what you tried to decode this parameters.
– Daniel Roseman
Nov 16 '18 at 12:47
It's running falcon to handle the request. As I mentioned, I tried json.(methods) but it doesn't work. The problem is that the data is serialized through $.param and then sent over the the server.
– Fotis Papadamis
Nov 16 '18 at 12:51
It's running falcon to handle the request. As I mentioned, I tried json.(methods) but it doesn't work. The problem is that the data is serialized through $.param and then sent over the the server.
– Fotis Papadamis
Nov 16 '18 at 12:51
No that is not the problem. But you need to show your Falcon code. What did you try to pass to the json method? And do you actually need a JSON string, or a dict? What are you hoping to do with the data?
– Daniel Roseman
Nov 16 '18 at 12:57
No that is not the problem. But you need to show your Falcon code. What did you try to pass to the json method? And do you actually need a JSON string, or a dict? What are you hoping to do with the data?
– Daniel Roseman
Nov 16 '18 at 12:57
I tried both dumps and loads. I'm reading the data using req.stream.read(). That's what I tried to pass in dumps and loads. I didn't post my Falcon code because I keep changing it all the time, I can't manage to get the data to be converted in json.
– Fotis Papadamis
Nov 16 '18 at 13:01
I tried both dumps and loads. I'm reading the data using req.stream.read(). That's what I tried to pass in dumps and loads. I didn't post my Falcon code because I keep changing it all the time, I can't manage to get the data to be converted in json.
– Fotis Papadamis
Nov 16 '18 at 13:01
@DanielRoseman posted what I get in my API. I tried to deserialize it with pickle but it didn't work. I can't find a way to convert it back to an object.
– Fotis Papadamis
Nov 16 '18 at 14:14
@DanielRoseman posted what I get in my API. I tried to deserialize it with pickle but it didn't work. I can't find a way to convert it back to an object.
– Fotis Papadamis
Nov 16 '18 at 14:14
add a comment |
1 Answer
1
active
oldest
votes
This is form-encoded data, which you can parse in Python using urllib.parse.parse_qs.
>>> from urllib import parse
>>> parse.parse_qs('name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2')
'name': ['Priority Rules'],
'rows[0][Segment]': ['HH wo TV'],
'rows[0][Value]': ['6'],
'rows[0][CampaignType]': ['CampaignType?'],
'rows[0][CampaignSubtype]': ['Predefined Contract'],
'rows[0][Channel]': ['WIND STORE'],
'rows[0][Priority]': ['1'],
'rows[1][Segment]': ['HH wo TV'],
'rows[1][Value]': ['6'],
'rows[1][CampaignType]': ['CampaignType?'],
'rows[1][CampaignSubtype]': ['Predefined Contract'],
'rows[1][Channel]': ['SMART WIND STORE MALL'],
'rows[1][Priority]': ['2']
I don't know Falcon, but I am sure that it has a way of accessing this data directly, without accessing the raw stream or passing into parse_qs. In Django or Flask you would get it via request.POST, which is a dictionary; skimming through the Falcon docs, it looks like req.params might do a similar job, although you may need to set the auto_parse_form_urlencoded option to True first.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338028%2fparam-serialized-object-to-json%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is form-encoded data, which you can parse in Python using urllib.parse.parse_qs.
>>> from urllib import parse
>>> parse.parse_qs('name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2')
'name': ['Priority Rules'],
'rows[0][Segment]': ['HH wo TV'],
'rows[0][Value]': ['6'],
'rows[0][CampaignType]': ['CampaignType?'],
'rows[0][CampaignSubtype]': ['Predefined Contract'],
'rows[0][Channel]': ['WIND STORE'],
'rows[0][Priority]': ['1'],
'rows[1][Segment]': ['HH wo TV'],
'rows[1][Value]': ['6'],
'rows[1][CampaignType]': ['CampaignType?'],
'rows[1][CampaignSubtype]': ['Predefined Contract'],
'rows[1][Channel]': ['SMART WIND STORE MALL'],
'rows[1][Priority]': ['2']
I don't know Falcon, but I am sure that it has a way of accessing this data directly, without accessing the raw stream or passing into parse_qs. In Django or Flask you would get it via request.POST, which is a dictionary; skimming through the Falcon docs, it looks like req.params might do a similar job, although you may need to set the auto_parse_form_urlencoded option to True first.
add a comment |
This is form-encoded data, which you can parse in Python using urllib.parse.parse_qs.
>>> from urllib import parse
>>> parse.parse_qs('name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2')
'name': ['Priority Rules'],
'rows[0][Segment]': ['HH wo TV'],
'rows[0][Value]': ['6'],
'rows[0][CampaignType]': ['CampaignType?'],
'rows[0][CampaignSubtype]': ['Predefined Contract'],
'rows[0][Channel]': ['WIND STORE'],
'rows[0][Priority]': ['1'],
'rows[1][Segment]': ['HH wo TV'],
'rows[1][Value]': ['6'],
'rows[1][CampaignType]': ['CampaignType?'],
'rows[1][CampaignSubtype]': ['Predefined Contract'],
'rows[1][Channel]': ['SMART WIND STORE MALL'],
'rows[1][Priority]': ['2']
I don't know Falcon, but I am sure that it has a way of accessing this data directly, without accessing the raw stream or passing into parse_qs. In Django or Flask you would get it via request.POST, which is a dictionary; skimming through the Falcon docs, it looks like req.params might do a similar job, although you may need to set the auto_parse_form_urlencoded option to True first.
add a comment |
This is form-encoded data, which you can parse in Python using urllib.parse.parse_qs.
>>> from urllib import parse
>>> parse.parse_qs('name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2')
'name': ['Priority Rules'],
'rows[0][Segment]': ['HH wo TV'],
'rows[0][Value]': ['6'],
'rows[0][CampaignType]': ['CampaignType?'],
'rows[0][CampaignSubtype]': ['Predefined Contract'],
'rows[0][Channel]': ['WIND STORE'],
'rows[0][Priority]': ['1'],
'rows[1][Segment]': ['HH wo TV'],
'rows[1][Value]': ['6'],
'rows[1][CampaignType]': ['CampaignType?'],
'rows[1][CampaignSubtype]': ['Predefined Contract'],
'rows[1][Channel]': ['SMART WIND STORE MALL'],
'rows[1][Priority]': ['2']
I don't know Falcon, but I am sure that it has a way of accessing this data directly, without accessing the raw stream or passing into parse_qs. In Django or Flask you would get it via request.POST, which is a dictionary; skimming through the Falcon docs, it looks like req.params might do a similar job, although you may need to set the auto_parse_form_urlencoded option to True first.
This is form-encoded data, which you can parse in Python using urllib.parse.parse_qs.
>>> from urllib import parse
>>> parse.parse_qs('name=Priority+Rules&rows%5B0%5D%5BSegment%5D=HH+wo+TV&rows%5B0%5D%5BValue%5D=6&rows%5B0%5D%5BCampaignType%5D=CampaignType%3F&rows%5B0%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B0%5D%5BChannel%5D=WIND+STORE&rows%5B0%5D%5BPriority%5D=1&rows%5B1%5D%5BSegment%5D=HH+wo+TV&rows%5B1%5D%5BValue%5D=6&rows%5B1%5D%5BCampaignType%5D=CampaignType%3F&rows%5B1%5D%5BCampaignSubtype%5D=Predefined+Contract&rows%5B1%5D%5BChannel%5D=SMART+WIND+STORE+MALL&rows%5B1%5D%5BPriority%5D=2')
'name': ['Priority Rules'],
'rows[0][Segment]': ['HH wo TV'],
'rows[0][Value]': ['6'],
'rows[0][CampaignType]': ['CampaignType?'],
'rows[0][CampaignSubtype]': ['Predefined Contract'],
'rows[0][Channel]': ['WIND STORE'],
'rows[0][Priority]': ['1'],
'rows[1][Segment]': ['HH wo TV'],
'rows[1][Value]': ['6'],
'rows[1][CampaignType]': ['CampaignType?'],
'rows[1][CampaignSubtype]': ['Predefined Contract'],
'rows[1][Channel]': ['SMART WIND STORE MALL'],
'rows[1][Priority]': ['2']
I don't know Falcon, but I am sure that it has a way of accessing this data directly, without accessing the raw stream or passing into parse_qs. In Django or Flask you would get it via request.POST, which is a dictionary; skimming through the Falcon docs, it looks like req.params might do a similar job, although you may need to set the auto_parse_form_urlencoded option to True first.
edited Nov 16 '18 at 15:26
answered Nov 16 '18 at 14:50
Daniel RosemanDaniel Roseman
460k42596655
460k42596655
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338028%2fparam-serialized-object-to-json%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You haven't really explained enough about what you are doing. What is handling this request? Your server is not just "Python", presumably it's running some kind of framework - which? You need to show the server-side code and what you tried to decode this parameters.
– Daniel Roseman
Nov 16 '18 at 12:47
It's running falcon to handle the request. As I mentioned, I tried json.(methods) but it doesn't work. The problem is that the data is serialized through $.param and then sent over the the server.
– Fotis Papadamis
Nov 16 '18 at 12:51
No that is not the problem. But you need to show your Falcon code. What did you try to pass to the json method? And do you actually need a JSON string, or a dict? What are you hoping to do with the data?
– Daniel Roseman
Nov 16 '18 at 12:57
I tried both dumps and loads. I'm reading the data using req.stream.read(). That's what I tried to pass in dumps and loads. I didn't post my Falcon code because I keep changing it all the time, I can't manage to get the data to be converted in json.
– Fotis Papadamis
Nov 16 '18 at 13:01
@DanielRoseman posted what I get in my API. I tried to deserialize it with pickle but it didn't work. I can't find a way to convert it back to an object.
– Fotis Papadamis
Nov 16 '18 at 14:14