UPDATED: Hierarchical Textfile to JSON

Hi everyone,

i have this Sample-Textfile:

0 File 1 Player Ronaldo 2 Position 2 B 2 Weight 32 3 LastWeight 31 1 Player Pele

I read the File via Textinputstream. How can i convert this Sample dynamically to a JSON-Structure?

OK, i made a small Project, which will show you the (Tree)Structure of that, what i want.

I read the Textfile and parse every Line.
[h]Line-Syntax[/h]

Level + [Reference] + Tag + [Value]

Reference/Value are optional!

Any Object has maximum 5 Sublevels. Means Level from 1 to 5.

Look at the Screenshot, i want to parse these Objects (e.g. INDI, an Object is shown by Level 0) to a JSON-Structure. But i don’t know, how to start the Algorithm.

Parser-Project and Sample-Textfile

[h]Sample JSON-Output[/h]

{ "INDI": { "ID": "I1", "Names": [ { "Full": "Erika /Gabler/", "GIVN": "Erika", "SURN": "Gabler" } ], "BIRT": { "DATE": "12 SEP 1945", "PLAC": { "Name": "Tempelhof, amerikanischer Sektor, Berlin (West), Berlin, Deutschland", "FORM": "Stadtbezirk, Stadtteil, Stadt, Bundesland, Staat", "_LOC": "P6" }, "ChildrenOfFamily": [ { "ID": "F2" } ], "SpouseOfFamily": [ { "ID": "F1" } ], "Notes": [ { "Note": "Ehefrau von Max Mustermann", "CONT": [ { "Note": "- geboren am 12. September 1945 in Berlin-Tempelhof" } ] } ], "REFN": "1.a", "SEX": "F", "_UID": "A51E2894DC914C7997A3441C50B709F9544B" } } }
Would be great, if you can help me :wink:

You need to have a look at the Json part of the docs and then start writing your code. Your question is waaayyyy to generic for us to help you. Try something and if your computer explodes or your Json doesn’t come out the way you want then ask again - a specific question.