Cause
Receive a query, export user account mapping another platform user name password work.
At first glance is not suitable for writing program implementation, because it is a temporary and unique task, to define a task suitable for writing a program to achieve depends on two points:
- Whether it is a recurring task
- is time-consuming for programming more than manual processing
If it is repetitive task to use program implementation, once and for all, but if the implementation of a simple implementation is very complicated, it is worth to consider whether it is worthwhile to do, and if it is a temporary task, only one time, it is basically manual operation can be, but some of the links can do some tools to do. That's the way I'm doing this time.
Demand
One step is to extract the user name from the JSON data in the query and configure the mapped user name password uniformly, with the following data format:
{ "OK":true, "Data":{ "Page":0, "Size": -, "Content":[ { "id":1, "User":{ "username":"Test 1", "Phone":"11111111111" }, "CreateDate":"2020-12-23" }, ... ] }}
In this JSON data to extract the username and output by the format can be, this time you can consider the implementation of the tool, the implementation of a lot of methods, I use JS to achieve a, with the interface to operate a little easier,
- Enter Raw JSON
- Define extraction rules (separated by "/" as paths, arrays using "*")
- Define the output template (the extracted content is replaced with the variable "$xx")
- Click Process and copy, in the output content is processed data, and has been copied
Realize
- Convert the input JSON string to a JSON object
- According to the rules of circular parsing, the recursive implementation of the loop, the "*" in the rules to do a special treatment
- Take the end of the rule to replace the "$xx" in the template and log it to the output
- Finally, it outputs all the content and uses the JS code to make the selection-copy.
The code is too long to put, put a tool link, there is a need to see the source code on the line.
Online JSON processing gadget
Recommend
Jane Page--Jane from the Heart, the page by oneself
Working with JSON online