How to prevent ordering of json string during parsing using groovy jsonslurper? -
i have josn string below,
def input = '''{"name":"abul","age":30,"street":"uttara"}'''
after parsing json string input below,
def output = new groovy.json.jsonslurper().parsetext(input)
i got following value of output
'''{"age":30,"name":"abul","street":"uttara"}'''
but expect no change in order i.e, expected result
{"name":"abul","age":30,"street":"uttara"}
how can using same lib i.e, groovy.json.jsonslurper
you can't.
if want ordering, you'll have use json array.
an object unordered collection of 0 or more name/value pairs, name string , value string, number, boolean, null, object, or array.
an array ordered sequence of 0 or more values.
reference : http://www.rfc-editor.org/rfc/rfc7159.txt
Comments
Post a Comment