Jump to content

JSON to tuple string error


Mike Tom

Recommended Posts

Hello mikel17,

I've wondered whether we'd ever hear from you again. Welcome back.

I think this all would go more smoothly if you considered the data field's value to be, in terms of StreamBase datatypes, a list of list of strings, rather than list of tuples with string fields that have numeric names.

Using an exemplar anonymous schema tuple constructor function rather than a named schema constructor (which would be the better practice in a real app), just for the sake of a writing a concise example that I don't need to make a screenshot for, you could parse your JSON string like this:

parsejson_loose(tuple(string() as channel, list(list(string())) as data), '{"channel":"1","data":[["TEST",1586303655,1992,0.1]]}')Let's imagine that you've set the result of this expression to a field named myTuple upstream of your Iterate operator.

Then, in your Iterate operator:

Your Operation Settings > Iterate Over expression would then be

input1.myTuple.data[0]And your Output Settings > Additional Expressions first line of the grid there would be:

Action: Add, Field Name element, Expression: each.element

If you try to interpret that bottom level JSON array as a StreamBase tuple, it's just going to be painful.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...