commit | 9003f0419ba0b95fd3bf54d3ac07e558fc4eabc4 | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Tue Aug 29 20:37:46 2023 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Aug 29 20:37:46 2023 +0000 |
tree | 77ec2740277e4361522175b4f04e0a1d118c0e74 | |
parent | 1321c8ecf030029756612ab5f4da261ebcfd4c01 [diff] | |
parent | 560a8ee9560dc1a3bb156a354feb530e63e8772e [diff] |
[automerger skipped] Merge Android U (ab/10368041) am: 3e176e8a21 -s ours am: 2fbd9f23b6 -s ours am: ea442f1487 -s ours am: 560a8ee956 -s ours am skip reason: Merged-In I14a51df4bf0dfea66a69567f6d39ff4fbf357eaf with SHA-1 f2160038b0 is already in history Original change: https://googleplex-android-review.googlesource.com/c/platform/external/cbor-java/+/24182707 Change-Id: I65ce29f8e93a23ff1ce94c5405b1a7c2cdeb1226 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
A Java 7 implementation of RFC 7049: Concise Binary Object Representation (CBOR)
Add this to the dependencies section of your pom.xml file:
<dependency> <groupId>co.nstant.in</groupId> <artifactId>cbor</artifactId> <version>0.8</version> </dependency>
ByteArrayOutputStream baos = new ByteArrayOutputStream(); new CborEncoder(baos).encode(new CborBuilder() .add("text") // add string .add(1234) // add integer .add(new byte[] { 0x10 }) // add byte array .addArray() // add array .add(1) .add("text") .end() .build()); byte[] encodedBytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes); List<DataItem> dataItems = new CborDecoder(bais).decode(); for(DataItem dataItem : dataItems) { // process data item }
ByteArrayInputStream bais = new ByteArrayInputStream(encodedBytes); new CborDecoder(bais).decode(new DataItemListener() { @Override public void onDataItem(DataItem dataItem) { // process data item } });
This project uses the C4 process for all code changes.
Copyright 2013-2017 Constantin Rack Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.