LC 8 and JSON

Devin Asay devin_asay at byu.edu
Fri Nov 13 14:54:04 EST 2015


> On Nov 13, 2015, at 12:31 PM, Peter TB Brett <peter.brett at livecode.com> wrote:
> 
> On 13/11/2015 19:28, Devin Asay wrote:
>> Anyone used the JSON library with the latest LC 8 RC’s? I’m trying to do some simple testing and getting an error every time.
>> 
>> I have a stack with a button and a field. The button script is this:
>> 
>> on mouseUp
>>   answer file "Choose a JSON file:" as sheet
>>   if it is empty then exit to top
>>   put it into tJsonTxt
>>   put url ("file:" & tJsonTxt) into fld "rawJSON"
>>   put JsonImport(tJsonTxt) into tLCtext
>>   put tLCText is an array # do a  simple check to see what kind of data’s returned
>> end mouseUp
>> 
>> It always errors at put JsonImport: “execution error at line 6 (extension: error occurred with domain) near “runtime”, char 9”.
>> 
>> The JSON file is a simple example from http://json.org/example.html .
>> 
>> Do I just fundamentally not get how to use libraries in LC 8? I want to make sure I’m not doing something stupid before I start filing bug reports.
> 
> Don't worry, you're not doing anything wrong as far as I can tell.
> 
> Exactly which of the examples are you trying to import?

I tried the very first one

{
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}

And I tried the very last one:

{"menu": {
    "header": "SVG Viewer",
    "items": [
        {"id": "Open"},
        {"id": "OpenNew", "label": "Open New"},
        null,
        {"id": "ZoomIn", "label": "Zoom In"},
        {"id": "ZoomOut", "label": "Zoom Out"},
        {"id": "OriginalView", "label": "Original View"},
        null,
        {"id": "Quality"},
        {"id": "Pause"},
        {"id": "Mute"},
        null,
        {"id": "Find", "label": "Find..."},
        {"id": "FindAgain", "label": "Find Again"},
        {"id": "Copy"},
        {"id": "CopyAgain", "label": "Copy Again"},
        {"id": "CopySVG", "label": "Copy SVG"},
        {"id": "ViewSVG", "label": "View SVG"},
        {"id": "ViewSource", "label": "View Source"},
        {"id": "SaveAs", "label": "Save As"},
        null,
        {"id": "Help"},
        {"id": "About", "label": "About Adobe CVG Viewer..."}
    ]
}}

 
I just copy-pasted them into BBEdit and saved them out as text files.

Devin

Devin Asay
Office of Digital Humanities
Brigham Young University



More information about the use-livecode mailing list