inputdata:
I want to change all keys are in same:-
like 0,1,2, keys are changed to $id for all how to fix this ..suggest .
Best answer by Bikram
View originalinputdata:
I want to change all keys are in same:-
like 0,1,2, keys are changed to $id for all how to fix this ..suggest .
Best answer by Bikram
View original
Can you please check if the below code snippet will resolve the issue or not ?
Please use it in jython evaluator processor.
import json
json_str = '{"0":10456.89,"1":10456.89,"2":10456.89,"3":10456.89,"4":10456.89,"5":10456.89,"6":10567.89,"7":10678.89,"8":10899.89,"9":10999.89}'
#new_dict = {}
# Sample Jython code
for record in sdc.records:
try:
data_dict = json.loads(json_str)
#s1 = #fun(data_dict)
s1 = [{"id":val} for val in data_dict.values()]
record.value['data1'] = json.dumps(s1)
# Write record to processor output
sdc.output.write(record)
except Exception as e:
# Send record to error
sdc.error.write(record, str(e))
Can you please check if the below code snippet will resolve the issue or not ?
Please use it in jython evaluator processor.
import json
json_str = '{"0":10456.89,"1":10456.89,"2":10456.89,"3":10456.89,"4":10456.89,"5":10456.89,"6":10567.89,"7":10678.89,"8":10899.89,"9":10999.89}'
#new_dict = {}
# Sample Jython code
for record in sdc.records:
try:
data_dict = json.loads(json_str)
#s1 = #fun(data_dict)
s1 = [{"id":val} for val in data_dict.values()]
record.value['data1'] = json.dumps(s1)
# Write record to processor output
sdc.output.write(record)
except Exception as e:
# Send record to error
sdc.error.write(record, str(e))
how can i give field of values to this jypthon evaluvator.
Please try the below ode snippet and let. me know if it. helps.
import json
for record in sdc.records:
try:
data_dict = json.loads(record.value['assigned_to'])
#s1 = #fun(data_dict)
s1 = [{"id":val} for val in data_dict.values()]
record.value['data1'] = json.dumps(s1)
# Write record to processor output
sdc.output.write(record) except Exception as e:
# Send record to error
sdc.error.write(record, str(e))
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.