haxetink / tink_json

Macro powered JSON.
The Unlicense
34 stars 9 forks source link

Fall back to haxe.Json for Dynamic values #18

Closed kevinresol closed 7 years ago

kevinresol commented 7 years ago

Sometimes we really need Dynamic in a JSON (say for some REST api we cannot change)

back2dos commented 7 years ago

Can you elaborate on that? What do you do with the Dynamic value once it is parsed?

kevinresol commented 7 years ago

Here: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange

The 'values' field is actually Array<Array<Dynamic>>

In spreadsheets term, it is rows of data and each cell may contain mixed types: strings, numbers, etc

back2dos commented 7 years ago

I generally plan to use tink.json.Value for arbitrary JSON. The way I see it, it could cover your use case. Is that correct?

kevinresol commented 7 years ago

Is that for the "dynamic part" only or the whole json? I think it would be more easy to use if it is just for the dynamic part

back2dos commented 7 years ago

The idea is to have it just for a part:

var valueRange:{
  range: String,
  majorDimension: String,
  values: Array<tink.json.Value>
} = tink.Json.parse(theString);

And tink.json.Representation over tink.json.Value should work too, of course.

kevinresol commented 7 years ago

Yeah that looks good 👍