Last active
June 16, 2018 04:07
-
-
Save plucury/d7eab810e27a83866f2d35b56f364e62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"type": "checkbox_field", | |
"index": 0, | |
"key": "checked", | |
"value": " " | |
}, | |
{ | |
"type": "checkbox_field", | |
"index": 0, | |
"key": "title_text", | |
"value": "Text to agree" | |
}, | |
{ | |
"type": "initial_field", | |
"index": 1, | |
"key": "initial_position", | |
"value": "0" | |
}, | |
{ | |
"type": "initial_field", | |
"index": 1, | |
"key": "title_text", | |
"value": "Please type your name initials" | |
}, | |
{ | |
"type": "initial_field", | |
"index": 1, | |
"key": "initial_text", | |
"value": "" | |
}, | |
{ | |
"type": "short_answer_field", | |
"index": 2, | |
"key": "answer", | |
"value": "" | |
}, | |
{ | |
"type": "short_answer_field", | |
"index": 2, | |
"key": "title_text", | |
"value": "Question text" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 3, | |
"key": "allow_other_choice", | |
"value": "False" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 3, | |
"key": "title_text", | |
"value": "Question text" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 3, | |
"key": "result_list", | |
"value": "list##False&&False&&False" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 3, | |
"key": "choice_list", | |
"value": "list##Default Choice&&More Choice&&More Choice" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 3, | |
"key": "other_choice", | |
"value": "" | |
}, | |
{ | |
"type": "date_field", | |
"index": 4, | |
"key": "format", | |
"value": "0" | |
}, | |
{ | |
"type": "date_field", | |
"index": 4, | |
"key": "month", | |
"value": "" | |
}, | |
{ | |
"type": "date_field", | |
"index": 4, | |
"key": "title_text", | |
"value": "Please fill your birth" | |
}, | |
{ | |
"type": "date_field", | |
"index": 4, | |
"key": "year", | |
"value": "" | |
}, | |
{ | |
"type": "date_field", | |
"index": 4, | |
"key": "day", | |
"value": "" | |
}, | |
{ | |
"type": "age_field", | |
"index": 5, | |
"key": "title_text", | |
"value": "Please fill in your age" | |
}, | |
{ | |
"type": "age_field", | |
"index": 5, | |
"key": "age", | |
"value": "" | |
}, | |
{ | |
"type": "name_field", | |
"index": 6, | |
"key": "format", | |
"value": "0" | |
}, | |
{ | |
"type": "name_field", | |
"index": 6, | |
"key": "middle_name", | |
"value": "" | |
}, | |
{ | |
"type": "name_field", | |
"index": 6, | |
"key": "show_middle_name", | |
"value": "False" | |
}, | |
{ | |
"type": "name_field", | |
"index": 6, | |
"key": "last_name", | |
"value": "" | |
}, | |
{ | |
"type": "name_field", | |
"index": 6, | |
"key": "title_text", | |
"value": "Please fill in your name" | |
}, | |
{ | |
"type": "name_field", | |
"index": 6, | |
"key": "first_name", | |
"value": "" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "state", | |
"value": "" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "first_line", | |
"value": "" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "second_line", | |
"value": "" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "title_text", | |
"value": "Please fill in your address" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "country", | |
"value": "" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "city", | |
"value": "" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "show_country", | |
"value": "False" | |
}, | |
{ | |
"type": "address_field", | |
"index": 7, | |
"key": "zipcode", | |
"value": "" | |
}, | |
{ | |
"type": "age_field", | |
"index": 8, | |
"key": "title_text", | |
"value": "Please fill in your age" | |
}, | |
{ | |
"type": "age_field", | |
"index": 8, | |
"key": "age", | |
"value": "" | |
}, | |
{ | |
"type": "short_answer_field", | |
"index": 9, | |
"key": "answer", | |
"value": "" | |
}, | |
{ | |
"type": "short_answer_field", | |
"index": 9, | |
"key": "title_text", | |
"value": "Question text" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 10, | |
"key": "allow_other_choice", | |
"value": "False" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 10, | |
"key": "title_text", | |
"value": "Question text" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 10, | |
"key": "result_list", | |
"value": "list##False&&False" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 10, | |
"key": "choice_list", | |
"value": "list##Default Choice&&Second Choice" | |
}, | |
{ | |
"type": "single_choice_field", | |
"index": 10, | |
"key": "other_choice", | |
"value": "" | |
}, | |
{ | |
"type": "multiple_choice_field", | |
"index": 11, | |
"key": "allow_other_choice", | |
"value": "False" | |
}, | |
{ | |
"type": "multiple_choice_field", | |
"index": 11, | |
"key": "title_text", | |
"value": "Question text" | |
}, | |
{ | |
"type": "multiple_choice_field", | |
"index": 11, | |
"key": "result_list", | |
"value": "list##False&&False" | |
}, | |
{ | |
"type": "multiple_choice_field", | |
"index": 11, | |
"key": "choice_list", | |
"value": "list##Default Choice&&Second Choice" | |
}, | |
{ | |
"type": "multiple_choice_field", | |
"index": 11, | |
"key": "other_choice", | |
"value": "" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "fixed", | |
"value": "False" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "max_count", | |
"value": "10" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "fields", | |
"value": "list##dict##format::0$$type::name_field$$optional::True$$show_middle_name::False$$last_name::$$title_text::name of minor$$id::0$$first_name::$$middle_name::&&dict##format::0$$type::name_field$$optional::True$$show_middle_name::False$$last_name::$$title_text::name of guardian$$id::1$$first_name::$$middle_name::&&dict##type::signature_field$$optional::True$$id::2$$title_text::signature of guardian$$signature_data::" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "result_list", | |
"value": "list##dict##format::0$$type::name_field$$middle_name::$$show_middle_name::False$$last_name::$$title_text::name of minor$$first_name::&&dict##format::0$$type::name_field$$middle_name::$$show_middle_name::False$$last_name::$$title_text::name of guardian$$first_name::" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "title", | |
"value": "please enter your minors' information" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "count", | |
"value": "1" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "min_count", | |
"value": "0" | |
}, | |
{ | |
"type": "container_field", | |
"index": 12, | |
"key": "id", | |
"value": "14" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"title_text": "Text to agree", | |
"checked": " ", | |
"type": "checkbox_field" | |
}, | |
{ | |
"initial_text": "", | |
"initial_position": "0", | |
"title_text": "Please type your name initials", | |
"type": "initial_field" | |
}, | |
{ | |
"title_text": "Question text", | |
"answer": "", | |
"type": "short_answer_field" | |
}, | |
{ | |
"choice_list": [ | |
"Default Choice", | |
"More Choice", | |
"More Choice" | |
], | |
"allow_other_choice": false, | |
"result_list": [ | |
false, | |
false, | |
false | |
], | |
"title_text": "Question text", | |
"other_choice": "", | |
"type": "single_choice_field" | |
}, | |
{ | |
"day": "", | |
"year": "", | |
"format": "0", | |
"title_text": "Please fill your birth", | |
"month": "", | |
"type": "date_field" | |
}, | |
{ | |
"title_text": "Please fill in your age", | |
"age": "", | |
"type": "age_field" | |
}, | |
{ | |
"show_middle_name": false, | |
"first_name": "", | |
"format": "0", | |
"title_text": "Please fill in your name", | |
"last_name": "", | |
"middle_name": "", | |
"type": "name_field" | |
}, | |
{ | |
"second_line": "", | |
"first_line": "", | |
"zipcode": "", | |
"show_country": false, | |
"title_text": "Please fill in your address", | |
"state": "", | |
"type": "address_field", | |
"city": "", | |
"country": "" | |
}, | |
{ | |
"title_text": "Please fill in your age", | |
"age": "", | |
"type": "age_field" | |
}, | |
{ | |
"title_text": "Question text", | |
"answer": "", | |
"type": "short_answer_field" | |
}, | |
{ | |
"choice_list": [ | |
"Default Choice", | |
"Second Choice" | |
], | |
"allow_other_choice": false, | |
"result_list": [ | |
false, | |
false | |
], | |
"title_text": "Question text", | |
"other_choice": "", | |
"type": "single_choice_field" | |
}, | |
{ | |
"choice_list": [ | |
"Default Choice", | |
"Second Choice" | |
], | |
"allow_other_choice": false, | |
"result_list": [ | |
false, | |
false | |
], | |
"title_text": "Question text", | |
"other_choice": "", | |
"type": "multiple_choice_field" | |
}, | |
{ | |
"max_count": 10, | |
"id": 14, | |
"fixed": false, | |
"title": "please enter your minors' information", | |
"result_list": [ | |
{ | |
"show_middle_name": false, | |
"first_name": "", | |
"format": "0", | |
"title_text": "name of minor", | |
"last_name": "", | |
"middle_name": "", | |
"type": "name_field" | |
}, | |
{ | |
"show_middle_name": false, | |
"first_name": "", | |
"format": "0", | |
"title_text": "name of guardian", | |
"last_name": "", | |
"middle_name": "", | |
"type": "name_field" | |
} | |
], | |
"min_count": 0, | |
"count": 1, | |
"fields": [ | |
{ | |
"show_middle_name": false, | |
"id": 0, | |
"first_name": "", | |
"format": "0", | |
"middle_name": "", | |
"title_text": "name of minor", | |
"optional": true, | |
"last_name": "", | |
"type": "name_field" | |
}, | |
{ | |
"show_middle_name": false, | |
"id": 1, | |
"first_name": "", | |
"format": "0", | |
"middle_name": "", | |
"title_text": "name of guardian", | |
"optional": true, | |
"last_name": "", | |
"type": "name_field" | |
}, | |
{ | |
"title_text": "signature of guardian", | |
"id": 2, | |
"signature_data": "", | |
"optional": true, | |
"type": "signature_field" | |
} | |
], | |
"type": "container_field" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dump_field_value(value): | |
if isinstance(value, list): | |
return 'list##' + '&&'.join([dump_field_value(v) for v in value]) | |
if isinstance(value, dict): | |
res = [] | |
for k, v in value.items(): | |
res.append('::'.join([k, dump_field_value(v)])) | |
return 'dict##'+'$$'.join(res) | |
return str(value) | |
def dump_other_fields(other_fields_all): | |
idx = 0 | |
ret = [] | |
for field in other_fields_all: | |
t = field.get('type') | |
for k, v in field.items(): | |
if k == 'type': | |
continue | |
v = dump_field_value(v) | |
ret.append({'type': t, 'index': idx, 'key': k, | |
'value': v}) | |
idx += 1 | |
return ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment