I do not know what's the JSON! I just know it contains some certain fields,
somewhere inside - some date-times, geo info (string formatted) and the
like. Now parsing these data needs certain unmarshalers. But I know the
name of those fields - not their position (they are not necessarily a
direct field of the JSON, but maybe a field of a child JSON object).
Token seems interesting! I'll look into it.
On Tuesday, April 4, 2017 at 4:55:39 PM UTC+4:30, Egon wrote:
>
> What is the JSON input that you need to parse?
>
> + Egon
>
> On Tuesday, 4 April 2017 13:54:34 UTC+3, dc0d wrote:
>>
>> Target: Assuming we want to deserialize some JSON dynamically and we want
>> to unmarshal some fields using specific unmarshaling code (a
>> certain UnmarshalJSON). The problem is using something like
>> map[string]interface{} there is no way to specify that.
>>
>> Thought Experiment: I like to have something like:
>>
>> ourUnmarshaler.AddField("name", func() json.Unmarshaler /* default field
>> creator for unmarshaling */, /* other options like omitempty */)
>>
>> or perhaps possibility of using:
>>
>> map[string]struct{
>> Name string
>> Constructor func() json.Unmarshaler
>> OmitEmpty bool
>> String bool
>> // ...
>> }
>>
>> That would be the ideal thing. But is it possible to do so with current
>> builtin tools? Or some package?
>>
>> Other notes:
>> I've found gabs <https://github.com/Jeffail/gabs> but it does not what I
>> want. Some of my specific cases are big int64 values which should
>> serialized as string because they get converted to ugly float things and
>> some custom parsing for specific strings.
>>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.