jacky998877 Posted November 2, 2022 Posted November 2, 2022 #include <File.au3> #include <JSON.au3> $sFilePath = @ScriptDir & "Latin.json" $hFileOpen = FileOpen($sFilePath, $FO_READ) there is a line inside the Latin.json file that looks like this {"pos": "verb", "head_templates": [{"name": "la-verb-form", "args": {"1": "abestis"}, "expansion": "abestis"}], "word": "abestis", "lang": "Latin", "lang_code": "la", "senses": [{"raw_glosses": ["second-person plural present active indicative of absum"], "glosses": ["second-person plural present active indicative of absum"], "tags": ["active", "form-of", "indicative", "plural", "present", "second-person"], "form_of": [{"word": "absum"}], "id": "abestis-la-verb-so45elH9", "categories": []}]} and i want to get this line through the word "abestis" using this code , and it didnt work out ConsoleWrite("name = " & json_Get($oJSON, '["word"]') & @CRLF)
bogQ Posted November 3, 2022 Posted November 3, 2022 (edited) On 11/2/2022 at 1:21 AM, jacky998877 said: #include <JSON.au3> and i want to get this line through the word "abestis" using this code , and it didnt work out That library is not included in standard Autoit, so we don't know which one you use. With using Wards library #include <Json.au3> $data = '{"pos": "verb", "head_templates": [{"name": "la-verb-form", "args": {"1": "abestis"}, "expansion": "abestis"}], "word": "abestis", "lang": "Latin", "lang_code": "la", "senses": [{"raw_glosses": ["second-person plural present active indicative of absum"], "glosses": ["second-person plural present active indicative of absum"], "tags": ["active", "form-of", "indicative", "plural", "present", "second-person"], "form_of": [{"word": "absum"}], "id": "abestis-la-verb-so45elH9", "categories": []}]}' $Obj = Json_Decode($data) ConsoleWrite("data is equal = " & Json_Get($Obj, '[word]') & @CRLF) ;data is equal = abestis Edited November 3, 2022 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
mikell Posted November 3, 2022 Posted November 3, 2022 For such a simple request maybe you could use a simpler way $line = '{"pos": "verb", "head_templates": [{"name": "la-verb-form", "args": {"1": "abestis"}, "expansion": "abestis"}], "word": "abestis", "lang": "Latin", "lang_code": "la", "senses": [{"raw_glosses": ["second-person plural present active indicative of absum"], "glosses": ["second-person plural present active indicative of absum"], "tags": ["active", "form-of", "indicative", "plural", "present", "second-person"], "form_of": [{"word": "absum"}], "id": "abestis-la-verb-so45elH9", "categories": []}]}' Msgbox(0,"", "name = " & StringRegExpReplace($line, '.*?"word":\s"([^"]+).*', "$1") )
Zedna Posted November 10, 2022 Posted November 10, 2022 (edited) @mikell Your code returns wrongly "abestis". EDIT: Sorry, I badly read not whole JSON line. Edited November 10, 2022 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now