How to debug JSON files - json

There are several errors in my JSON file. What is the best option for debugging JSON files? I used this editor - http://www.jsoneditoronline.org/, but it's a bit difficult to use for long files.
For instance, the error message says:
Error: Parse error on line 1:
...000.0}]}},"data": [{"id": 0,"fr
-----------------------^
Expecting 'EOF', '}', ',', ']', got ':'"
But the line looks fine.

Try putting your JSON file's content into a validator, like http://jsonlint.com/ or http://jsonformatter.curiousconcept.com/ and see what it says.

I suggest entering your JSON into a linter such as http://jsonlint.com/. Additionally, properly formatting your JSON will make it easier to debug. A site such as http://jsonformatter.curiousconcept.com/ can do this for you.

If you have access to NodeJS locally, there's a CLI tool that works well for linting JSON files: https://github.com/zaach/jsonlint
Otherwise, you can use JSONLint if you don't mind uploading your JSON to a "random" remote server.

If you have access to Visual Studio. They have a visualizer debugging tool, which as such, will traverse the structure and throw at the problematic lines.
JSON Debugger Visualizer in Visual Studio 2013

Why not try something like vim or Notepad++ and try matching the brackets and braces? You may need to use something to "pretty print" the JSON first. I believe you could do that from a Python console.
You may try something from here http://jsbeautifier.org/ to format in one-line JSON stuff.

You can use Codverter JSON Validator, its online but it`s highly secure and everything you do is interpreted on your local computer and never sent back to the server. the validation error messages are informative and accurate.
(Full Disclosure: I am one of the developers).

Related

Why am I seeing a red icon instead of a json icon on the left corner on VS Code?

When I try to run this code it says code language is not supported even though I have set it to JSON. I keep getting this error. How to fix??
JSON (JavaScript Object Notation) is just a file format that is used to exchange data from servers. It is not a programming language that you can run. The file package.json is used mainly for configuration with package managers.

Protobuf data + .proto -> JSON

OK, I have a protobuf formatted data file. I also have a .proto file that describes the schema of the file.
I have found copious libraries that let me extract known messages out of the file. How nice.
However, I don't really know the structure of the file. There may be different top-level "messages" in the file, and what I really want to do is just inspect the file and get a dump of what's in it.
Would love to have a command that lets me do something like:
proto2json <format.proto> <datafile> -o <output.json>
Is this too much to ask for? The Google isn't yielding an obvious answer, so maybe there's something subtle about protobufs I don't get yet.
Ideas?
Thanks to some helpful people on the protocol-buffers google group, I have an answer.
The answer is, "sorry, no".
Well, close. The problem is it's up to you to know what the "root" message is in the data file. In my case it wasn't obvious, so I was hoping a dump of the file would divulge the root. No luck, as the file itself doesn't know what the fields or messages are, they just have data that you can extract if you have the right .proto file.
In my case, I had a few suspicions as to what the root might be, so I did trial and error until I found the message that seemed to know what all of the fields are in the file.
It would have been nice if the .proto file indicated what the root message is, in which case I'm sure a tool to do this conversion would exist already.
I hope this helps.
Here's a pass at solving the problem that you posed. Here's an example command line to run this tool.
$ ./proto2json.sh --schema=test/test.proto \
--root=Recording --in=test/test.pb --out=out.json
https://github.com/rohitsaboo/proto2json
Currently, the tool only supports protocol buffer schemas that do not depend on protos from other files. However, it should be possible to extend it to support "dependency_schemas".

How to convert a ".trx" file to HTML

I generate my tests suite with vstest.console with VS 2012 and get my test result in a .trx format file.
I want to convert this result file toHTML. I used the trx2html tool. But I get an error when I run it.
Error : System.IO.FileLoadException
trx2html.exe C:\Users...\Desktop\result.trx
How can I solve this problem?
Do other tools exist that allow converting a .trx file to html or pdf ?
One more thing, I'm using orderedtest so my trx file come from orderedtest created by VS2012
There were some issues with trx2html tool and vs2012, so I suppose you have the latest version from Codeplex (http://trx2html.codeplex.com/).
Although obviating the error, this question may be useful for you:
How do I format Visual Studio Test results file (.trx) into a more readable format?

Fiware wirecloud widget upload: error no valid parser found

I want to create a widget and upload it to my FIWARE Mashup Workspace. When I upload my ".wgt" file I get the error:
Error adding packaged resource: Error parsing config.xml descriptor
file: No valid parser found.
How can I get more information about the error?
Is it simply a parsing error, or is something different went wrong (no valid parser found sounds like some service is missing)
Is there a way to check my config.xml file?
This is definitely a configuration error; there is no service missing.
Since your config is in xml, check it with an XML checker, to be sure that no opening/closing tags are missing.
If your wgt is an operator, check that your preferences/endpoints have different IDs. Also, please be sure that all your endpoints use distinct names

SSIS: HTML Encoding a URL in a Script Task

I would like to URL encode a URL in a C# SSIS script task. I have tried using System.Web.HttpServerUtility, but intellisense shows it doesn't seem to be aware of "Server". Here's an example of the code that's raising an error:
Import System.Web
...
...
...
Server.HtmlEncode(TestVariable);
I have worked around this issue by writing a function that finds and replaces characters in a string to mimic HTML encoding a string, but I honestly abhore the solution. I would really just like to find out what I need to differently to use what's baked into .NET instead of reinventing the HTML Encoder wheel.
You need to add a reference to the assembly System.Web