json icon indicating copy to clipboard operation
json copied to clipboard

json to Value,disordered arrangement order, how can we keep it as it is?

Open zhangwuqiao opened this issue 2 years ago • 1 comments

I have a project where the key values in the passed in JSON are uncertain, but they must be analyzed and processed in the order in which they were passed in. However, when converting JSON to Value, the order is out of order. How to use 'from_str' Convert to Value in the order in which it is passed in?

Eg:

图片 图片

zhangwuqiao avatar May 07 '23 12:05 zhangwuqiao

See the preserve_order feature https://github.com/serde-rs/json/blob/931ee23b1abf6b302df7c20a3a5866bf1a8a33ca/Cargo.toml#L58-L61

kangalio avatar May 23 '23 17:05 kangalio