美文网首页
fastjson之JSONPath

fastjson之JSONPath

作者: 爱的旋转体 | 来源:发表于2023-03-03 16:08 被阅读0次

json-path不能为空,json字符串也不能为空

1、json字符串中没有所要的字段,返回null

JSONArray jsonArray = JSONPath.compile("$.user.address").eval("{\"user\":{}}", JSONArray.class);
System.out.println(jsonArray);
image.png

2、json字符串中有所要的字段

JSONArray jsonArray = JSONPath.compile("$.user.address").eval("{\"user\":{\"address\":[]}}", JSONArray.class);
System.out.println(jsonArray);
image.png

相关文章

  • fastjson之JSONPath

    json-path不能为空,json字符串也不能为空 1、json字符串中没有所要的字段,返回null 2、jso...

  • JAVA 转换 树结构数据

    JAVA 转换 树结构数据 第一步:引入fastjson 第二步:用到了工具内的JSONPath JSONPath...

  • Snack3 之 Jsonpath使用

    Snack3 之 Jsonpath使用 一、 Snack3 和 JSONPath 介绍 Snack3 是一个支持J...

  • Kubectl之JSONPath

    背景 最近接到一个需求,需要通过kubectl命令展示出一些特定的字段,比如只显示pod name和host ip...

  • 11.jsonpath模块

    jsonpath模块 知识点 -了解 jsonpath模块的使用场景 -掌握 jsonpath模块的使用 1. j...

  • 1,JsonPath简介

    1,Jayway JsonPath Jayway JsonPath是一个读取json文档的java DSL 实现 ...

  • python之jsonpath模块

    安装方法:pip install jsonpath官方文档:http://goessner.net/article...

  • Jsonpath快速去深层次的json

    1.jsonpath

  • JsonPath 语法手册

    JsonPath基本用法 本文主要介绍JsonPath的基本语法,并演示如何在Newtonsoft.Json中进行...

  • Python_JsonPath

    JsonPath基本用法 本文主要介绍JsonPath的基本语法,并演示如何在Newtonsoft.Json中进行...

网友评论

      本文标题:fastjson之JSONPath

      本文链接:https://www.haomeiwen.com/subject/eateldtx.html