dartwatch-JsonObject icon indicating copy to clipboard operation
dartwatch-JsonObject copied to clipboard

access JSON element with a _ or @ in the name

Open fils opened this issue 11 years ago • 2 comments

I am working with JSON_LD which has elements like @context and _links in it.

I can get dart var sr = data.links; to work but dart var sr = data._links; or var sr = data.'_links'; don't..

is there a way to access elements of json with non alpha numeric first characters?

fils avatar Jun 10 '13 15:06 fils

Same here, I'm seeing this error with the '_' as the first character, CouchDB uses fields like '_rev' for instance, these don't play nicely maybe because Dart sees '_rev' as a private member and can't return it publicly without a getter?

shamblett avatar Jun 14 '13 07:06 shamblett

Weird. I'd think a _private getter would still pass through noSuchMethod.

You can always use the Map function data["_links"].

stevenroose avatar Apr 02 '15 01:04 stevenroose