`
jubincn
  • 浏览: 242617 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
文章分类
社区版块
存档分类
最新评论

google-json2.0的UserGuide

 
阅读更多

site.google.com被墙了,找朋友搞了一份2.0版本的,发在这里共享之。

目录
1 Overview
2 Goals for Gson
3 Gson Performance and Scalability
4 Gson Users
5 Using Gson
5.1 Primitives Examples
5.2 Object Examples
5.2.1 Finer Points with Objects
5.3 Nested Classes (including Inner Classes)
5.4 Array Examples
5.5 Collections Examples
5.5.1 Collections Limitations
5.6 Serializing and Deserializing Generic Types
5.7 Serializing and Deserializing Collection with Objects of Arbitrary Types
5.8 Built-in Serializers and Deserializers
5.9 Custom Serialization and Deserialization
5.9.1 Writing a Serializer
5.9.2 Writing a Deserializer
5.10 Writing an Instance Creator
5.10.1 InstanceCreator for a Parameterized Type
5.11 Compact Vs. Pretty Printing for JSON Output Format
5.12 Null Object Support
5.13 Versioning Support
5.14 Excluding Fields From Serialization and Deserialization
5.14.1 Java Modifier Exclusion
5.14.2 Gson's @Expose
5.14.3 User Defined Exclusion Strategies
5.15 JSON Field Naming Support
5.16 Sharing State Across Custom Serializers and Deserializers
5.17 Streaming
6 Issues in Designing Gson
7 Future Enhancements to Gson


Overview

Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson is an open-source project hosted at http://code.google.com/p/google-gson.

Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.

Goals for Gson

Provide easy to use mechanisms like toString() and constructor (factory method) to convert Java to JSON and vice-versa
Allow pre-existing unmodifiable objects to be converted to and from JSON
Allow custom representations for objects
Support arbitrarily complex object
Generate compact and readability JSON output
Gson Performance and Scalability

Here are some metrics that we obtained on a desktop (dual opteron, 8GB RAM, 64-bit Ubuntu) running lots of other things along-with the tests. You can rerun these tests by using the class PerformanceTest.
Strings: Deserialized strings of over 25MB without any problems (see disabled_testStringDeserializationPerformance method in PerformanceTest)
Large collections:
Serialized a collection of 1.4 million objects (see disabled_testLargeCollectionSerialization method in PerformanceTest)
Deserialized a collection of 87,000 objects (see disabled_testLargeCollectionDeserialization in PerformanceTest)
Gson 1.4 raised the deserialization limit for byte arrays and collection to over 11MB from 80KB.
Note: Delete the disabled_ prefix to run these tests. We use this prefix to prevent running these tests every time we run junit tests.

Gson Users

Gson was originally created for use inside Google where it is currently used in a number of projects. It is now used by a number of public projects and companies. See details here.

Using Gson

The primary class to use is Gson which you can just create by calling new Gson(). There is also a class GsonBuilder available that can be used to create a Gson instance with various settings like version control and so on.

The Gson instance does not maintain any state while invoking Json operations. So, you are free to reuse the same object for multiple Json serialization and deserialization operations.

Primitives Examples

(Serialization)
Gson gson = new Gson();
gson.toJson(1); ==> prints 1
gson.toJson("abcd"); ==> prints "abcd"
gson.toJson(new Long(10)); ==> prints 10
int[] values = { 1 };
gson.toJson(values); ==> prints [1]

(Deserialization)
int one = gson.fromJson("1", int.class);
Integer one = gson.fromJson("1", Integer.class);
Long one = gson.fromJson("1", Long.class);
Boolean false = gson.fromJson("false", Boolean.class);
String str = gson.fromJson("\"abc\"", String.class);
String anotherStr = gson.fromJson("[\"abc\"]", String.class);

Object Examples

class BagOfPrimitives {
private int value1 = 1;
private String value2 = "abc";
private transient int value3 = 3;
BagOfPrimitives() {
// no-args constructor
}
}

(Serialization)
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);
==> json is {"value1":1,"value2":"abc"}

Note that you can not serialize objects with circular references since that will result in infinite recursion.

(Deserialization)
BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
==> obj2 is just like obj

Finer Points with Objects

It is perfectly fine (and recommended) to use private fields
There is no need to use any annotations to indicate a field is to be included for serialization and deserialization. All fields in the current class (and from all super classes) are included by default.
If a field is marked transient, (by default) it is ignored and not included in the JSON serialization or deserialization.
This implementation handles nulls correctly
While serialization, a null field is skipped from the output
While deserialization, a missing entry in JSON results in setting the corresponding field in the object to null
If a field is synthetic, it is ignored and not included in JSON serialization or deserialization
Fields corresponding to the outer classes in inner classes, anonymous classes, and local classes are ignored and not included in serialization or deserialization
Nested Classes (including Inner Classes)

Gson can serialize static nested classes quite easily.

Gson can also deserialize static nested classes. However, Gson can not automatically deserialize the pure inner classes since their no-args constructor also need a reference to the containing Object which is not available at the time of deserialization. You can address this problem by either making the inner class static or by providing a custom InstanceCreator for it. Here is an example:

public class A {
public String a;


class B {
public String b;


public B() {
// No args constructor for B
}
}
}


NOTE: The above class B can not (by default) be serialized with Gson.

Gson can not deserialize {"b":"abc"} into an instance of B since the class B is an inner class. if it was defined as static class B then Gson would have been able to deserialize the string. Another solution is to write a custom instance creator for B.

public class InstanceCreatorForB implements InstanceCreator<A.B> {
private final A a;
public InstanceCreatorForB(A a) {
this.a = a;
}
public A.B createInstance(Type type) {
return a.new B();
}
}

The above is possible, but not recommended.

Array Examples

Gson gson = new Gson();
int[] ints = {1, 2, 3, 4, 5};
String[] strings = {"abc", "def", "ghi"};

(Serialization)
gson.toJson(ints); ==> prints [1,2,3,4,5]
gson.toJson(strings); ==> prints ["abc", "def", "ghi"]

(Deserialization)
int[] ints2 = gson.fromJson("[1,2,3,4,5]", int[].class);
==> ints2 will be same as ints

We also support multi-dimensional arrays, with arbitrarily complex element types

Collections Examples

Gson gson = new Gson();
Collection<Integer> ints = Lists.immutableList(1,2,3,4,5);

(Serialization)
String json = gson.toJson(ints); ==> json is [1,2,3,4,5]

(Deserialization)
Type collectionType = new TypeToken<Collection<Integer>>(){}.getType();
Collection<Integer> ints2 = gson.fromJson(json, collectionType);

ints2 is same as ints

Fairly hideous: note how we define the type of collection
Unfortunately, no way to get around this in Java

Collections Limitations

Can serialize collection of arbitrary objects but can not deserialize from it
Because there is no way for the user to indicate the type of the resulting object
While deserializing, Collection must be of a specific generic type
All of this makes sense, and is rarely a problem when following good Java coding practices

Serializing and Deserializing Generic Types

When you call toJson(obj), Gson calls obj.getClass() to get information on the fields to serialize. Similarly, you can typically pass MyClass.class object in the fromJson(json, MyClass.class) method. This works fine if the object is a non-generic type. However, if the object is of a generic type, then the Generic type information is lost because of Java Type Erasure. Here is an example illustrating the point:

class Foo<T> {
T value;
}
Gson gson = new Gson();
Foo<Bar> foo = new Foo<Bar>();
gson.toJson(foo); // May not serialize foo.value correctly

gson.fromJson(json, foo.getClass()); // Fails to deserialize foo.value as Bar

The above code fails to interpret value as type Bar because Gson invokes list.getClass() to get its class information, but this method returns a raw class, Foo.class. This means that Gson has no way of knowing that this is an object of type Foo<Bar>, and not just plain Foo.

You can solve this problem by specifying the correct parameterized type for your generic type. You can do this by using the TypeToken class.

Type fooType = new TypeToken<Foo<Bar>>() {}.getType();

gson.toJson(foo, fooType);
gson.fromJson(json, fooType);

The idiom used to get fooType actually defines an anonymous local inner class containing a method getType() that returns the fully parameterized type.
Serializing and Deserializing Collection with Objects of Arbitrary Types

Sometimes you are dealing with JSON array that contains mixed types. For example:
['hello',5,{name:'GREETINGS',source:'guest'}]

The equivalent Collection containing this is:
Collection collection = new ArrayList();
collection.add("hello");
collection.add(5);
collection.add(new Event("GREETINGS", "guest"));
Where the Event class is defined as:
class Event {
private String name;
private String source;
private Event(String name, String source) {
this.name = name;
this.source = source;
}
}

You can serialize the collection with Gson without doing anything specific: toJson(collection) would write out the desired output.
However, deserialization with fromJson(json, Collection.class) will not work since Gson has no way of knowing how to map the input to the types. Gson requires that you provide a genericised version of collection type in fromJson. So, you have three options:

Option 1: Use Gson's parser API (low-level streaming parser or the DOM parser JsonParser) to parse the array elements and then use Gson.fromJson() on each of the array elements.This is the preferred approach. Here is an example that demonstrates how to do this.

Option 2: Register a type adapter for Collection.class that looks at each of the array members and maps them to appropriate objects. The disadvantage of this approach is that it will screw up deserialization of other collection types in Gson.

Option 3: Register a type adapter for MyCollectionMemberType and use fromJson with Collection<MyCollectionMemberType>
This approach is practical only if the array appears as a top-level element or if you can change the field type holding the collection to be of type Collection<MyCollectionMemberTyep>.
Built-in Serializers and Deserializers

Gson has built-in serializers and deserializers for commonly used classes whose default representation may be inappropriate.
Here is a list of such classes:
java.net.URL to match it with strings like "http://code.google.com/p/google-gson/".
java.net.URI to match it with strings like "/p/google-gson/".
You can also find source-code for some commonly used classes such as JodaTime at this page.
Custom Serialization and Deserialization

Sometimes default representation is not what you want. This is often the case when dealing with library classes (DateTime, etc).
Gson allows you to register your own custom serializers and deserializers. This is done by defining two parts:
Json Serialiers: Need to define custom serialization for an object
Json Deserializers: Needed to define custom deserialization for a type
Instance Creators: Not needed if no-args constructor is available or a deserializer is registered
GsonBuilder gson = new GsonBuilder();
gson.registerTypeAdapter(MyType2.class, new MyTypeAdapter());
gson.registerTypeAdapter(MyType.class, new MySerializer());
gson.registerTypeAdapter(MyType.class, new MyDeserializer());
gson.registerTypeAdapter(MyType.class, new MyInstanceCreator());

registerTypeAdapter call checks if the type adapter implements more than one of these interfaces and register it for all of them.
Writing a Serializer

Here is an example of how to write a custom serializer for JodaTime DateTime class.

private class DateTimeSerializer implements JsonSerializer<DateTime> {
public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.toString());
}
}

Gson calls toJson() when it runs into a DateTime object during serialization.

Writing a Deserializer

Here is an example of how to write a custom deserializer for JodaTime DateTime class.

private class DateTimeDeserializer implements JsonDeserializer<DateTime> {
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return new DateTime(json.getAsJsonPrimitive().getAsString());
}
}

Gson calls fromJson() when it needs to deserialize a JSON string fragment into a DateTime object

Finer points with Serializers and Deserializers

Often you want to register a single handler for all generic types corresponding to a raw type
For example, suppose you have an "Id" class for Id representation/translation (i.e. an internal vs. external representation).
Id<T> type that has same serialization for all generic types
Essentially write out the id value
Deserialization is very similar but not exactly the same

Need to call "new Id(Class<T>, String)" which returns an instance of Id<T>
Gson supports registering a single handler for this. You can also register a specific handler for a specific generic type (say Id<RequiresSpecialHandling> needed special handling).
The Type parameter for the toJson and fromJson contains the generic type information to help you write a single handler for all generic types corresponding to the same raw type

Writing an Instance Creator

While deserializing an Object, Gson needs to create a default instance of the class
Well-behaved classes that are meant for serialization and deserialization should have a no-argument constructor
Doesn't matter whether public or private
Typically, Instance Creators are needed when you are dealing with a library class that does NOT define a no-argument constructor

Instance Creator Example

private class MoneyInstanceCreator implements InstanceCreator<Money> {
public Money createInstance(Type type) {
return new Money("1000000", CurrencyCode.USD);
}
}

Type could be of a corresponding generic type
Very useful to invoke constructors which need specific generic type information
For example, if the Id class stores the class for which the Id is being created

InstanceCreator for a Parameterized Type

Sometimes that the type that you are trying to instantiate is a parameterized type. Generally, this is not a problem since the actual instance is of raw type. Here is an example:

class MyList<T> extends ArrayList<T> {
}

class MyListInstanceCreator implements InstanceCreator<MyList<?>> {
@SuppressWarnings("unchecked")
public MyList<?> createInstance(Type type) {
// No need to use a parameterized list since the actual instance will have the raw type anyway.
return new MyList();
}
}

However, sometimes you do need to create instance based on the actual parameterized type. In this case, you can use the type parameter being passed to the createInstance method. Here is an example:

public class Id<T> {
private final Class<T> classOfId;
private final long value;
public Id(Class<T> classOfId, long value) {
this.classOfId = classOfId;
this.value = value;
}
}

class IdInstanceCreator implements InstanceCreator<Id<?>> {
public Id<?> createInstance(Type type) {
Type[] typeParameters = ((ParameterizedType)type).getActualTypeArguments();
Type idType = typeParameters[0]; // Id has only one parameterized type T
return Id.get((Class)idType, 0L);
}
}

In the above example, an instance of the Id class can not be created without actually passing in the actual type for the parameterized type. We solve this problem by using the passed method parameter, type. The type object in this case is the Java parameterized type representation of Id<Foo> where the actual instance should be bound to Id<Foo>. Since Id class has just one parameterized type parameter, T, we use the zeroth element of the type array returned by getActualTypeArgument() which will hold Foo.class in this case.

Compact Vs. Pretty Printing for JSON Output Format

The default JSON output that is provide by Gson is a compact JSON format. This means that there will not be any whitespace in the output JSON structure. Therefore, there will be no whitespace between field names and its value, object fields, and objects within arrays in the JSON output. As well, "null" fields will be ignored in the output (NOTE: null values will still be included in collections/arrays of objects). See the Null Object Support section for information on configure Gson to output all null values.

If you like to use the Pretty Print feature, you must configure your Gson instance using the GsonBuilder. The JsonFormatter is not exposed through our public API, so the client is unable to configure the default print settings/margins for the JSON output. For now, we only provide a default JsonPrintFormatter that has default line length of 80 character, 2 character indentation, and 4 character right margin.

The following is an example shows how to configure a Gson instance to use the default JsonPrintFormatter instead of the JsonCompactFormatter:

Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonOutput = gson.toJson(someObject);

Null Object Support

The default behaviour that is implemented in Gson is that null object fields are ignored. This allows for a more compact output format; however, the client must define a default value for these fields as the JSON format is converted back into its Java.

Here's how you would configure a Gson instance to output null:
Gson gson = new GsonBuilder().serializeNulls().create();

NOTE: when serializing nulls with Gson, it will add a JsonNull element to the JsonElement structure. Therefore, this object can be used in custom serialization/deserialization.

Here's an example:

public class Foo {
private final String s;
private final int i;

public Foo() {
this(null, 5);
}

public Foo(String s, int i) {
this.s = s;
this.i = i;
}
}

Gson gson = new GsonBuilder().serializeNulls().create();
Foo foo = new Foo();
String json = gson.toJson(foo);
System.out.println(json);

json = gson.toJson(null);
System.out.println(json);

======== OUTPUT ========
{"s":null,"i":5}
null

Versioning Support

Multiple versions of the same object can be maintained by using @Since annotation. This annotation can be used on Classes, Fields and, in a future release, Methods. In order to leverage this feature, you must configure your Gson instance to ignore any field/object that is greater than some version number. If no version is set on the Gson instance then it will serialize and deserialize all fields and classes regardless of the version.

public class VersionedClass {
@Since(1.1) private final String newerField;
@Since(1.0) private final String newField;
private final String field;

public VersionedClass() {
this.newerField = "newer";
this.newField = "new";
this.field = "old";
}
}

VersionedClass versionedObject = new VersionedClass();
Gson gson = new GsonBuilder().setVersion(1.0).create();
String jsonOutput = gson.toJson(someObject);
System.out.println(jsonOutput);
System.out.println();

gson = new Gson();
jsonOutput = gson.toJson(someObject);
System.out.println(jsonOutput);


======== OUTPUT ========
{"newField":"new","field":"old"}

{"newerField":"newer","newField":"new","field":"old"}

Excluding Fields From Serialization and Deserialization

Gson supports numerous mechanisms for excluding top-level classes, fields and field types. Below are pluggable mechanism that allow field and class exclusion. If none of the below mechanism satisfy your needs then you can always use custom serializers and deserializers.

Java Modifier Exclusion

By default, if you mark a field as transient, it will be excluded. As well, if a field is marked as "static" then by default it will be excluded. If you want to include some transient fields then you can do the following:

import java.lang.reflect.Modifier;

Gson gson = new GsonBuilder()
.excludeFieldsWithModifier(Modifier.STATIC)
.create();

NOTE: you can use any number of the Modifier constants to "excludeFieldsWithModifier" method. For example:
Gson gson = new GsonBuilder()
.excludeFieldsWithModifier(Modifier.STATIC, Modifier.TRANSIENT, Modifier.VOLATILE)
.create();
Gson's @Expose

This feature provides a way where you can mark certain fields of your objects to be excluded for consideration for serialization and deserialization to JSON. To use this annotation, you must create Gson by using new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(). The Gson instance created will exclude all fields in a class that are not marked with @Expose annotation.

User Defined Exclusion Strategies

If the above mechanisms for excluding fields and class type do not work for you then you can always write your own exclusion strategy and plug it into Gson. See the ExclusionStrategy JavaDoc for more information.

The following example shows how to exclude fields marked with a specific "@Foo" annotation and excludes top-level types (or declared field type) of class String.
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Foo {
// Field tag only annotation
}

public class SampleObjectForTest {
@Foo private final int annotatedField;
private final String stringField;
private final long longField;
private final Class<?> clazzField;

public SampleObjectForTest() {
annotatedField = 5;
stringField = "someDefaultValue";
longField = 1234;
}
}

public class MyExclusionStrategy implements ExclusionStrategy {
private final Class<?> typeToSkip;

private MyExclusionStrategy(Class<?> typeToSkip) {
this.typeToSkip = typeToSkip;
}

public boolean shouldSkipClass(Class<?> clazz) {
return (clazz == typeToSkip);
}

public boolean shouldSkipField(FieldAttributes f) {
return f.getAnnotation(Foo.class) != null;
}
}

public static void main(String[] args) {
Gson gson = new GsonBuilder()
.setExclusionStrategies(new MyExclusionStrategy(String.class))
.serializeNulls()
.create();
SampleObjectForTest src = new SampleObjectForTest();
String json = gson.toJson(src);
System.out.println(json);
}

======== OUTPUT ========
{"longField":1234}

JSON Field Naming Support

Gson supports some pre-defined field naming policies to convert the standard Java field names (i.e. camel cased names starting with lower case --- "sampleFieldNameInJava") to a Json field name (i.e. sample_field_name_in_java or SampleFieldNameInJava). See the FieldNamingPolicy class for information on the pre-defined naming policies.

It also has an annotation based strategy to allows clients to define custom names on a per field basis. Note, that the annotation based strategy has field name validation which will raise "Runtime" exceptions if an invalid field name is provided as the annotation value.

The following is an example of how to use both Gson naming policy features:

private class SomeObject {
@SerializedName("custom_naming") private final String someField;
private final String someOtherField;

public SomeObject(String a, String b) {
this.someField = a;
this.someOtherField = b;
}
}

SomeObject someObject = new SomeObject("first", "second");
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create();
String jsonRepresentation = gson.toJson(someObject);
System.out.println(jsonRepresentation);


======== OUTPUT ========
{"custom_naming":"first","SomeOtherField":"second"}

If you have a need for custom naming policy (see this discussion), you can use the @SerializedName annotation.
Sharing State Across Custom Serializers and Deserializers

Sometimes you need to share state across custom serializers/deserializers (see this discussion). You can use the following three strategies to accomplish this:
Store shared state in static fields
Declare the serializer/deserializer as inner classes of a parent type, and use the instance fields of parent type to store shared state
Use Java ThreadLocal
1 and 2 are not thread-safe options, but 3 is.

Streaming

In addition Gson's object model and data binding, you can use Gson to read from and write to a stream. You can also combine streaming and object model access to get the best of both approaches.

Issues in Designing Gson

See the Gson design document for a discussion of issues we faced while designing Gson. It also include a comparison of Gson with other Java libraries that can be used for Json conversion.

Future Enhancements to Gson

For the latest list of proposed enhancements or if you'd like to suggest new ones, see the Issues section under the project website

分享到:
评论

相关推荐

    JSON-RPC 2.0 规范(中文版)

    ### JSON-RPC 2.0 规范解析 #### 概述 JSON-RPC 2.0 是一种无状态、轻量级的远程过程调用(RPC)协议,旨在简化跨网络的应用通信流程。该规范定义了一系列数据结构及处理规则,以支持不同消息传输环境(如基于 ...

    iview-admin2.0-ts.zip

    《Iview-admin2.0集成TypeScript的框架详解》 Iview-admin2.0是一个基于Vue.js的管理后台模板,其2.0版本引入了TypeScript的支持,为开发者提供了更加强大的类型检查和代码提示功能,提升了开发效率和代码质量。在`...

    struts2-json-plugin

    struts2-json-plugin,Struts JSON插件

    struts2-blank-2.0.11.2.war

    struts2-blank-2.0.11.2

    LoveString-v2.0.zip

    例如,在处理大量CSV或JSON文件时,如果它们的编码不一致,使用LoveString-v2.0可以快速统一编码格式,避免手动操作的繁琐和出错风险。 此外,LoveString-v2.0不仅仅局限于文件转换,它还具备对字符串的直接操作...

    android-json-0.0.20131108.vaadin1-API文档-中文版.zip

    标签:external、vaadin、android、json、google、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,...

    node-jsonrpc2:JSON-RPC 2.0服务器和客户端库,带有HTTP(具有Websocket支持)和TCP端点

    带有HTTP (具有Websocket支持)和TCP端点的JSON-RPC 2.0服务器和客户端库 此派生用适当的测试框架,线性代码,与节点0.8.x和0.10.x兼容,类继承和附加功能进行了重写 工具类 检查对该模块的一些不错的补充。 安装 ...

    Laravel开发-laravel-jsonrpc

    **Laravel 开发:深入理解 Laravel JSON-RPC 2.0 服务器** Laravel 是一个流行的、优雅的 PHP 框架,它为开发者提供了构建高效、可维护的 web 应用程序的强大工具。JSON-RPC(JSON Remote Procedure Call)是一种轻...

    json-lib-2.1.jar和struts2-json-plugin-2.1.8.1.jar

    在Java世界里,`json-lib-2.1.jar` 是一个用于处理JSON的库,它提供了一系列的方法来将Java对象转换为JSON格式,以及将JSON字符串反序列化回Java对象。这个库支持多种Java类型,包括基本类型、集合、Map、自定义Java...

    fping-msys2.0.zip

    标题中的“fping-msys2.0.zip”指的是一个压缩包文件,其中包含了名为“fping”的工具在MSYS2环境下的版本2.0。fping是一个命令行工具,类似于ping,但支持同时对多个IP地址进行并发扫描,非常适合网络监控和性能...

    京东SDK调用实例(open-api-sdk-2.0.jar)

    本文将深入探讨如何使用"open-api-sdk-2.0.jar"这个特定版本的京东SDK,帮助开发者实现便捷的API调用。 首先,我们要了解SDK的基本概念。SDK是一组工具、库和文档,旨在简化开发过程,使得开发者能够快速集成特定...

    lib-flexible-2.0

    "lib-flexible-2.0" 是一个专用于网页自适应的JavaScript库,它主要解决的是在不同设备和屏幕尺寸下网页布局与显示的问题。在移动互联网时代,随着各种智能设备的广泛使用,网页设计必须考虑多终端适配,这就需要...

    jersey-media-json-jackson-2.0.jar

    java运行依赖jar包

    struts-2.0.11.2-lib

    在这个"struts-2.0.11.2-lib"压缩包中,包含了Struts2.0.11.2版本所需的所有核心库文件,这些文件对于理解和使用Struts2框架至关重要。 1. **Struts2的核心组件**: - `struts2-core.jar`:这是Struts2框架的核心...

    json-lib-2.0-jdk15-sources.zip

    “json-lib-2.0-jdk15-sources.zip”这个压缩包提供了JSON库的一个具体实现——json-lib的源代码。json-lib是一个Java项目的开源库,主要用于处理JSON格式的数据。它支持多种Java平台,包括JDK1.5。源代码的提供对于...

    Ajax 修炼之道-Web 2.0 入门

    **Ajax 修炼之道-Web 2.0 入门** Ajax(Asynchronous JavaScript and XML)是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术。它使得网页更加动态和交互,是Web 2.0的核心特性之一。通过Ajax,开发者...

    JSON RPC 2.0

    JSON RPC 2.0是该协议的一个重要版本,它在JSON RPC 1.0的基础上进行了改进,增加了错误处理机制和批量调用功能,使得通信更加规范和高效。 1. **协议概述**: JSON RPC 2.0基于JSON(JavaScript Object Notation...

    WorizonJsonRpc:基于 HTTP 的 JSON-RPC 2.0 的 Java 库

    JSON-RPC 2.0 规范 该库实现的大部分规范都可以在上找到。 有一个小组讨论规范和相关问题。 用法 该库旨在通过外观类Rpc 使用。 这个类公开了两种执行 rpc 请求的方法: 代理 API。 常规 API。 代理 api创建一个...

    json-smart-2.0-RC3

    json-smart-2.0-RC3.jar 亲测,可用!

    RESTFUL的实现-springboot2.0版本

    例如,我们可以创建一个`List&lt;User&gt;`,然后在控制器中使用这些方法来操作这个列表。GET请求可能遍历列表并返回所有用户,POST请求可能将新用户添加到列表,PUT请求更新列表中的用户,而DELETE请求从列表中移除用户。...

Global site tag (gtag.js) - Google Analytics