Description

Extract json value from json string.

Parameters

Name Description Type Required? Default Value
jsonPath json path String[]
skipFailed skip Failed boolean false
selectedCol Name of the selected column used for processing String
reservedCols Names of the columns to be retained in the output table String[] null
outputCols Names of the output columns String[]

Script Example

Script

  1. import numpy as np
  2. import pandas as pd
  3. data = np.array([
  4. ["{a:boy,b:{b1:1,b2:2}}"],
  5. ["{a:girl,b:{b1:1,b2:2}}"]])
  6. df = pd.DataFrame({"str": data[:, 0]})
  7. streamData = dataframeToOperator(df, schemaStr='str string', op_type='stream')
  8. JsonValueStreamOp().setJsonPath(["$.a","$.b.b1"]).setSelectedCol("str").setOutputCols(["f0","f1"]).linkFrom(streamData).print()
  9. StreamOperator.execute()

Result

str f0 f1
{a:boy,b:{b1:1,b2:2}} boy 1
{a:girl,b:{b1:1,b2:2}} girl 1