Open Zhouenze opened 4 years ago
It seems like there are two issues here. The first is that you would like a way to get an IonElement
tree from a string, and the second is that you want to be able to serialize/deserialize the "metas".
IonElement
tree from a stringThis is already possible using the loadSingleElement
function, found here. For example:
loadSingleElement("(sexp (annotation::data))")
This is the equivalent to calling IonSystem::singleValue(...)
using ion-java
to get an IonValue
.
The "metas" are not actually part of the Ion data format, and there is no support for metas in IonValue
. To get the location metadata for IonElement
, you can do this:
import com.amazon.ionelement.util.INCLUDE_LOCATION_META
// ...
loadSingleElement("(sexp (annotation::data))", INCLUDE_LOCATION_META)
That will include the actual location in the metas, so the symbol data
will have metas with a location of line:1,column:8
(because the annotation::
starts at column 8).
Currently IonElement doesn't support creation from String that contain annotation & meta, it has to be created like this:
Instead of above, something like this would be much simpler:
parseFromString("(sexp (annotation::data meta={line:1,column:23}))")
This ability is present for
IonValue
, it would be great if we could have the same forIonElement
.Thanks!