Update operation about JSON string concatenation, JSON string and JSON object conversion

Source: Internet
Author: User

Update operation background

1     2     /**3 * Update Staff4      * @return"updatesdr"5      */6      publicString updatethesdr () {7Jsonstr = "{\" oid\ ":" +oid+ "}";8             Try {9                 //gets the JSON data for the selected objectTenReturnsdrupdate =OABOSVC.GETTHESDR (jsonstr); one                 //convert to JSON object aJsonobject Jasonobject =Jsonobject.fromobject (returnsdrupdate); -                 //get the corresponding value from the JSON object OID name phone -OID =jasonobject.getstring ("oid"); theString name =jasonobject.getstring ("name"); -String phone =jasonobject.getstring ("phone"); -System.out.println ("pre-modification information:------>" + "oid:" +oid+ "," + "name:" +name+ "," + "phone:" +phone); -                 //creates a new object that takes the obtained value to the object +FORMVO =NewSdsdper (); - formvo.setname (name); + Formvo.setphone (phone); a                  at}Catch(Exception E) { - e.printstacktrace (); -             } -             return"updatesdr"; -     } -     /** in * Click OK to update the modification information -      * @return to      * @throwsException +      */ -      publicString updatesdrinfo () { the             Try{ *                 //get the value of a page by Servelet $HttpServletRequest request=servletactioncontext.getrequest ();Panax NotoginsengName=request.getparameter ("formvo.name"); -Phone=request.getparameter ("formvo.phone"); the                 //Stitching JSON +Jsonstr = "{\" oid\ ":" +oid+ ", \" name\ ":" +name+ ", \" phone\ ":" +phone+ "}"; aSystem.out.println ("post-edit info:---->" +jsonstr); the                 //Calling Methods +Updatesdrinfo =OABOSVC.UPDATESDR (jsonstr); -Map map = (HashMap) Gsonutil.getobject (updatesdrinfo, HashMap.class); $                 //Print Operation results $ System.out.println (map); -Success = (Boolean) Map.get ("success"); - Promptinfo (success); the             } -             Catch(Exception E) {WuyiLog.error ("...... ..... ..... ........................ ..." +e.getmessage (...) + "..." ..... ..... ..... ..... ... "); the e.printstacktrace (); -             } wu             return NULL; -}

Reference: conversion between Java and JS in jsonobject,jsonarray,map,string-continuous update

This article is for personal records only

Available for reference

2017-11-13 09:02:13

Update operation about JSON string concatenation, JSON string and JSON object conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.