Creating and Manipulating JSON Objects with FastJSON in Java

This tutorial video demonstrates how to create JSON objects, add and retrieve data, handle escape characters, and format output using FastJSON in Java, accompanied by a full code example and references to related articles on deep/shallow copying and console formatting.

FunTester
FunTester
FunTester
Creating and Manipulating JSON Objects with FastJSON in Java

The author announces a video tutorial on basic operations with JSON objects, recorded spontaneously without extensive preparation, and invites feedback.

The video series includes three topics: an introductory overview of the FunTester testing framework, obtaining HTTP request objects, and sending requests with response parsing.

Due to platform length limits, the content is split into two videos: one covering JSON object creation and data addition, and another covering data retrieval and formatted output. A code snippet shows how to replace escaped forward slashes ("\\/" -> "//") in response strings.

For deeper understanding of shallow vs. deep copying and console output methods, the author refers readers to previous articles on JVM heap analysis and JSON console formatting.

Demo code:

package com.fun;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fun.frame.SourceCode;

public class Fun extends SourceCode {
    public static void main(String[] args) {
        // Example JSON string
        String jsonstr = "{\"22\":\"fdskjflsj\",\"221\":{\"2\":3243,\"213\":213243,\"32\":321243},\"2\":323333,\"222\":false,\"array\":[{\"2\":3243,\"213\":213243,\"32\":321243},{\"2\":3243,\"213\":213243,\"32\":321243},{\"2\":3243,\"213\":213243,\"32\":321243}]}";
        JSONObject jsonObject1 = JSON.parseObject(jsonstr);
        jsonObject1.put("array", "1/2");
        // output(jsonObject1.equals(json));
        output(jsonObject1);
        output(jsonObject1.getBooleanValue("222"));
        output(jsonObject1.getJSONObject("221"));
    }
}

The article includes a disclaimer that the content is originally published on the "FunTester" public account and should not be reproduced without permission (except by Tencent Cloud).

Additional sections list curated technical articles and non‑code articles covering topics such as Linux performance monitoring, performance testing frameworks, HTTP mind maps, and various testing best‑practice guides.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaCode Example
FunTester
Written by

FunTester

10k followers, 1k articles | completely useless

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.