Json Datei parsen

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Json Datei parsen

Re: Json Datei parsen

Post by just me » 26 Apr 2019, 02:07

Moin,

ein JSON-"Objekt" ist kein AHK-Objekt/Array. Für AHK ist es nur eine Zeichenkette (string).

Wenn es JSON ist, solltest Du Dir das mal ansehen: JSON 2.0 (and Jxon) - JSON lib for AutoHotkey.

Wenn Du willst, dass wir Dir helfen, musst Du Beispieldaten liefern, deren Aufbau dem Original entspricht. Ansonsten wird das hier ein 'sinnloses Rätselraten'.

Re: Json Datei parsen

Post by KHA » 26 Apr 2019, 01:28

Wieso funktioniert es dann mit:

Code: Select all

Arrays := [{"a":1,"b":2,"c":3}, {"a":4,"b":5,"c":6}]
der Unterschied ist doch die Eckigen klammen [ ] , das habe ich ergänzt.

Re: Json Datei parsen

Post by wolf_II » 25 Apr 2019, 17:44

Dein original Array ist keine kompatible AHK-syntax. Im original wird die zweite Hälfte (alles nach dem Komma) von AHK ignoriert.

Re: Json Datei parsen

Post by KHA » 25 Apr 2019, 17:38

Thanks for answering.
With test File is works. But not with Original File. There it is shown to me only 1 2 3 4 ....
idea why this could be ?

Re: Json Datei parsen

Post by wolf_II » 25 Apr 2019, 16:46

Try this: (Arrays is only loosely based on your original, and not a valid JSON-format)

Code: Select all

Arrays := [{"a":1,"b":2,"c":3}, {"a":4,"b":5,"c":6}]

Output := ""
for each, Array in Arrays
    for k, v in Array
        Output .= k "`t" v "`r`n"
MsgBox, % Output
return
I hope that helps.

Json Datei parsen

Post by KHA » 25 Apr 2019, 16:31

Guten Abend in die Runde,
habe eine json Datei die ist wie folgt aufgebaut (siehe Array).
Mit einer For-Schleife wird mir nur der erste Teil extrahiert
MsgBox:
a 1
b 2
c 3

Hätte das der MsgBox mir alle keys und values anzeigt, auch die, die sich im zweiten eckigen klammern befinden
a 1
b 2
c 3
a 4
b 5
c 6

Für Hilfe und Tipps wäre ich dankbar.

Code: Select all

Array := {"a":1,"b":2,"c":3}, {"a":4,"b":5,"c":6}

Output := ""
for k, v in Array
{
	Output .= k "`t" v "`r`n"
}
MsgBox, % Output
return

Top