I have this document which nicely uploads to robomongo but in mlab(mlab.com)it is showing JSON validation error.
Specifically ,"We encountered an error while parsing your JSON. Please check your syntax (e.g. ensure you are using double quotes around both your field names and values) and try again. " is making me nervous.
please check the document here.
That appears to be an array of JSON documents, not a single JSON document, which is what the mLab JSON document editor expects. In other words, an array is not a valid JSON document, even though its elements may be valid JSON documents.
Related
A colleague and I were trying to write the minimal logic that we needed for compacting, validating, parsing, and storing json coming from a client.
Upon doing so, we realized that compacting and validating were two steps that were both being accomplished by json.Compact anyways, since the code indicates json.Compact calls the json Scanner. The scanner then validates json and errors on invalid json.
The docs do not make this explicit, but we think this is the case.
Here is a link: https://forum.golangbridge.org/t/json-compact-appears-to-also-validate-json-but-is-not-documented/23088
Let us know thoughts.
Yes.
json.Compact uses json.scanner while scanning the json. If the scanner encounters invalid JSON sets scanner.err, which is returned by json.Compact if there is an error.
This is the same way json.Valid checks for valid json, by simply scanning the JSON and checking for scanner.err.
Here's the relevant code sections:
https://go.googlesource.com/go/+/go1.16.2/src/encoding/json/indent.go#17
https://go.googlesource.com/go/+/go1.16.2/src/encoding/json/scanner.go#30
I'm new to the World of triplets :-) I'm trying to use DotNetRDF to load the SOLR searchresult into a Graph using DotNetRDF.
The URL I'm getting data from is:
https://nvv.entryscape.net/store/search?type=solr&query=rdfType:https%5C%3A%2F%2Fnvv.entryscape.net%2Fns%2FDocument+AND+context:https%5C%3A%2F%2Fnvv.entryscape.net%2Fstore%2F1
The format is supposed to be "RDF/JSON". No matter what parser or what I try - I only get "invalid URI". Have tried to load from the URL and also tried downloadning the result to a file and load from file, same error.
I'm using VS2017 and have "nugetted" the latest version of DotNetRdf.
Please help me, what am I missing?
Regards,
Lars Siden
It looks like the JSON being returned by that endpoint is not valid RDF/JSON. It does appear to contain some RDF/JSON fragments but they are wrapped up inside another JSON structure. The RDFJSONParser in dotNetRDF requires that your entire JSON document be a single, valid chunk of RDF/JSON.
The value at resource.children[*].metadata is an RDF/JSON object. So is the value at resource.children[*].info. The rest is wrapper using property names that are not valid IRIs (hence the parser error message).
Unfortunately there is no easy way to skip over the rest of the JSON document and only parse the valid bits. To do that you will need to load the JSON document using Newtonsoft.JSON and then serialize each valid RDF/JSON object you are interested in as a string and load that using the RDFJSONParser's Load(IGraph, TextReader) or Parse(IRdfHandler, TextReader) method.
I'm using the sonarQube 6.4 web api to get a list of issues
http://sonar-server:9000/api/issues/search?componentKeys=Project_key&sinceLeakPeriod=true&statuses=OPEN,REOPENED&types=BUG
This gives me a Json object which has single quotes,
..."message":"Make this function anonymous by removing its name:
'function() {...}'."...
Because of that highlighted content in the JSON I'm unable to process the JSON from Groovy.
Is the JSON returned by the sonar is valid ?
if so, is there any way to process this kind of JSON in groovy.
Let me know if the full JSON object is needed.
According to http://json.org/ and https://jsonformatter.curiousconcept.com/ the JSON response is valid. Single quotes and brackets {} must not be escaped. The issue comes from your Groovy parser.
I have a PHP file that is queried for information, and it passes a couple of variables back. One variable contains a JSON string with a variable in the object called message, which comes escaped to prevent it from causing issues if the message has an ampersand, single quote, etc in it.
&data={"message":"star%27s"}
Obviously the data sent is more complicated, this is just an example. After I take the data passed back by the PHP file and use URLVariables to decode it and access the "data" variable, it ends up looking like:
{"message":"star's"}
At this point I can't parse the JSON string, it will throw an error because of the single quote. Encoding it wouldn't work, it would encode more than just everything after the colon.
Is there a way to keep it from converting it? I was thinking I could manually parse the PHP returned string, but it seems unnecessary and I don't want risk running into issues later on because of it. I looked at the AS3 API and I couldn't find anything documenting this or how to disable it.
Any ideas or suggestions?
You try with
Actionscript API escape() and unescape() see for more details Escape and unescape
Also look at JSON.parse and JSON.stringify working-with-native-json-in-flash-player-11
JSON decode in actionscript see decode-json
I'm using SJCL, and it works fine with small ASCII strings.
But when I try to decode this piece of JSON (the result of the encryption of an HTML page) I get a "this is not JSON!" error.
The JSON has been produced by SJCL, and while I did encode it and decode it using LZW and base64 I don't get this error for small strings with the same workflow.
I tracked the error message origin to the decode function. I assume the regexes are failing but I don't understand why as this seems to be a perfectly formed JSON string to me.
However, I can be wrong as if I do a JavaScript eval on it it fails on a syntax error. But if I dump it in a file Python parse it fine.
The json that is at your this piece of json link starts and ends with a double-quote character. Is that actually part of the contents of the json? If it is, I believe that is your problem. Otherwise, it looks like valid json to me.
Ok I made a double passed base64 encoding. One before encryption, and one after. It seems that removing the first pass make it work.