1

I wanted a tool that, given a simple text format, can parse it and output JSON that can be used elsewhere. The input would be of a syntax that is easy and quick to write by hand, but that JSON can represent natively in full.

This comes from a frustration from attempting to write JSON by hand; it's error prone and time-consuming especially when dealing with anything even slightly complex, not to mention the lack of a standard spacing / newline conventions.

After some searching I found ObjGen. This seems very close to what I want, however it isn't perfect (it can't handle certain constructs), and before I go and create my own open source version, I wanted to know if there's anything similar out there?

Edit - Further information

The construct I was referring to was a list of strings like this:

{
  "list_of_strings": [
    "hello", 
    "hello, again",
    "goodbye"
  ]
}

It didn't seem possible to express this in the ObjGen input format, because string arrays are always split on , even if escaped (in fact it doesn't support escaping control characters as far as I can tell, since \ is simply output as "\"). However I found that it can be achieved by using the ASCII code such as "hello &#44 again".

  • So you are not looking only for software, but also for an input format, right? – Nicolas Raoul Nov 2 '16 at 4:03
  • I don't understand the request. You already found ObjGen which is similar to what you want. What else do you need? The question does not describe in detail what you're missing ("certain constructs") and we can only guess what those constructs could be. – Thomas Weller Nov 2 '16 at 6:13
  • @Thomas The "certain constructs" were for example, the ability to have an array of strings which themselves contain commas. Due to the syntax design this was not immediately obvious but can actually be achieved by using ASCII values (e.g. &#44). – Arj Nov 8 '16 at 16:35
1

I've implemented Huge JSON Viewer in C# with JSON.NET. For C#, you can use SharpDevelop as an IDE for it.

  • This looks like a nice bit of software, but am I right in assuming it's Windows only? – Arj Nov 8 '16 at 14:20
  • @Arj: yes. It was developed on Windows and tested on Windows only. I have no idea whether or not it will run e.g. on Mono – Thomas Weller Nov 8 '16 at 14:24
0

I would suggest taking a look at the tools available in Python.

For Input

There are lots of ways to parse your input text ranging from using the super powerful regular expressions in re to using the textX library to define your input syntax and automatically create a parser for it.

For Output

The built in JSON Library is very good and extensible or its fork simplejson can be used - the later has the advantage that you can upgrade it independent of your python version.

0

As you pointed out to ObjGen - there seem to be few other online tools, perhaps better suited for JSON:

http://oleg.fi/relaxed-json/

https://hjson.org/try.html

I've added similar, experimental (not tested thoroughly yet) tool to JSONedit: JSONedit: relaxed parser It is supposed to help with creating small and medium size structures to be pasted into main editor (e.g. as element of some bigger object).

It should work with Wine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.