Is there a limit for array size in QJson? - json

I am working with QT 5.5 and I get a json with QNetwork and I try to parse it.
The json object is like this :
{
"cas_version":1008,
"result":"true",
"diaporamas":
{
"0":
{
"diaporamaid":5,
"diaporamamaj":1440433023,
"slides":
{
"0":{"slideid":32,"slidecontent":"html content here"}
}
}
}
If i run my program with this, no problem, the json is correctly parsed.
But if i have more than 10 elements inside slides, i get this error :"illegal value"
The json is generated by PHP5.5
Thank !

Thank you very much, it was not an issue in the json part (which is missing a "}"). The problem was when Qt downloading the file, the file was corrupted (I open the buffer too early)

Related

.SerializationException: Start of structure or map found where not expected

I am trying to define a JSON object in such a way that it would show output after processing as below-
resolvedEntities={failedEntities=null, resolvedEntities={Rewards$APPA$GetAllPromotions=[{"benefi"}]
but the below json code is throwing me SerializationException with saying Start of structure or map found where not expected.
{
"resolvedEntities": {
"failedEntities": "null",
"resolvedEntities": {
"Rewards$APPA$GetAllPromotions": "[{\"benefi\"}]"
}
}
}
Any suggestions for the correct way of defining the JSON for getting output as
resolvedEntities={failedEntities=null, resolvedEntities={Rewards$APPA$GetAllPromotions=[{"benefi"}] .

Facebook API - Batch upload photos

I'm trying to batch upload photos and I keep getting a response back from Postman saying "Batch parameter must be a JSON Array" Does anyone see what is wrong with this because it looks like valid json to me. I've been rattling with this for a few hours making minor tweaks trying to get it to upload to no avail. I also have tried encoding the url.
https://graph.facebook.com/v2.11?batch=[{"method":"POST", "relative_url":"https://graph.facebook.com/v2.11/{pageid}/photos?access_token={access-token}", "body":"link_url":"https://{link-to-image}/wmphotos/999995/6d5cc4169bbf4e7dbe31f3739e025412/a572c29dff_640.jpg"}]&access_token={access-token}
Looking at your code, it seems that the JSON object in your batch array is actually malformed. body:link_url:link should be body: {link_url:link}
Bad:
[
{
"method":"POST",
"relative_url":"foo",
"body":"link_url":"link"
}
]
Good:
[
{
"method":"POST",
"relative_url":"foo",
"body":{"link_url":"link"}
}
]

Unable to return right object from Json

I've used json for the below selenium ruby syntax
#driver.find_element(:css, "#poi-tabs *[class='tab ']")
This works as expected
#driver.find_element(:css, JSON.parse(file)['xyz']['elemen'])
But the below FAILS to work, since the value :css taken from .json file is not supporting here
#driver.find_element(JSON.parse(file)['xyz']['selecto'], JSON.parse(file)['xyz']['elemen'])
Note:
When I print "selecto" and "elemen", both brings the exact output but not sure about the format; is there any format to handle it ? or any other workaround
Available or.json
{
"xyz": {
"selecto": ":css",
"elemen": "#poi-tabs *[class='tab ']"
}
}
#driver.find_element(:css, JSON.parse(file)['xyz']['elemen'])
Here :css is a symbol whereas in
#driver.find_element(JSON.parse(file)['xyz']['selecto'], JSON.parse(file)['xyz']['elemen'])
:css is a string. So you are not getting desired result.
Try
#driver.find_element(eval(JSON.parse(file)['xyz']['selecto']), JSON.parse(file)['xyz']['elemen'])

How to parse json format having no array inside it on sencha platform

I am new to sencha so I have to set Data for which i am using this function component.setData( eval(WebServiceUtil.getAPIData('cartPage', 'getCartInfo')))
But when I am printing values inside cartPage.html file on console then I am not getting any json data there. So Can you give any suggestion for this format
I am fetching my json data from getCartInfo.txt file
[
{
"data":{
"unitPrice":56,
"shippingCity":"Mumbai",
"image":null,
"quantity":1,
"productId":"genpr-5",
"storePriceId":"12",
"customerIp":null,
"orderId":"2342",
"trackingCode":null,
"sessionId":"u48m6kn56k_66E4FE42F194803DB16D2692EA9DB608",
"storeId":"STORE-13",
"orderDetailId":null,
"productName":null,
"typeProduct":null,
"totalAmount":56,
"storeInventoryId":"5",
"toCurrency":null,
"inventorySensible":false,
"name":"Samsung Galaxy",
"customerId":"anonymous",
"fromCurrency":null,
"id":"EBEE13831114",
"currencyConversionRate":0,
"currencyCode":null
},
"response":"success"
}
]
I have solved my question by my own. The modification which i have done
is WebServiceUtil.getAPIData('cartPage', 'getCartInfo')[0].data which help ferch data from json.

JSON Variants (Log4J) with LogStash

I'm not sure if this is a follow-up or separate question to this one. There is some piece about LogStash that is not clicking. For that, I apologize for a related question. Still, I'm going out of my mind here.
I have an app that writes logs to a file. Each log entry is a JSON object. An example of my .json file looks like the following:
{
"logger":"com.myApp.ClassName",
"timestamp":"1456976539634",
"level":"ERROR",
"thread":"pool-3-thread-19",
"message":"Danger. There was an error",
"throwable":"java.Exception"
},
{
"logger":"com.myApp.ClassName",
"timestamp":"1456976539649",
"level":"ERROR",
"thread":"pool-3-thread-16",
"message":"I cannot go on",
"throwable":"java.Exception"
}
This format is what's created from Log4J2's JsonLayout. I'm trying my damnedest to get the log entries into LogStash. In an attempt to do this, I've created the following LogStash configuration file:
input {
file {
type => "log4j"
path => "/logs/mylogs.log"
}
}
output {
file {
path => "/logs/out.log"
}
}
When I open /logs/out.log, I see a mess. There's JSON. However, I do not see the "level" property or "thread" property that Log4J generates. An example of a record can be seen here:
{"message":"Danger. There was an error","#version":"1","#timestamp":"2014-04-08T17:20:10.035Z","type":"log4j","host":"ip-myAddress","path":"/logs/mylogs.log"}
Sometimes I even get parse errors. I need my properties to still be properties. I do not want them crammed into the message portion or the output. I have a hunch this has something to do with Codecs. Yet, I'm not sure. I'm not sure if I should change the codec on the logstash input configuration. Or, if I should change the input on the output configuration. I would sincerely appreciate any help as I'm getting desperate at this point.
Can you change your log format?
After I change your log format to
{ "logger":"com.myApp.ClassName", "timestamp":"1456976539634", "level":"ERROR", "thread":"pool-3-thread-19", "message":"Danger. There was an error", "throwable":"java.Exception" }
{ "logger":"com.myApp.ClassName", "timestamp":"1456976539649", "level":"ERROR", "thread":"pool-3-thread-16", "message":"I cannot go on", "throwable":"java.Exception" }
One json log per one line and without the "," at the end of the log, I can use the configuration below to parse the json message to correspond field.
input {
file {
type => "log4j"
path => "/logs/mylogs.log"
codec => json
}
}
input {
file {
codec => json_lines { charset => "UTF-8" }
...
}
}
should do the trick
Use Logstash's log4j input.
http://logstash.net/docs/1.4.2/inputs/log4j
Should look something like this:
input {
log4j {
port => xxxx
}
}
This worked for me, good luck!
I think #Ben Lim was right, your Logstash config is fine, just need to properly format input JSON to have each log event in a single line. This is very simple with Log4J2's JsonLayout, just set eventEol=true and compact=true. (reference)