在ObjectNode中用到了 数组格式百度了一下知道了这个用法`
先创建这个 这个就是数组
ArrayNode members = JsonNodeFactory.instance.arrayNode();
members.add(
//分账接收方类型
rootNode1.put("type", splitAmountAO.getSplitIdType())
//分账接收方帐号
.put("account",splitAmountAO.getSplitId())
分账个人接收方姓名
.put("amount",splitAmountAO.getSplitAmount())
//分账描述
.put("description",splitAmountAO.getDescription())
给数组里添加数据 上面就是
然后把数组的内容放到 objectnode里面
rootNode.putArray("receivers").addAll(members);
整体是这样的

void DFSpart(int start);
void findindegree(int *array);
bool Hamiton(int start,int *&path,int &count);
void Criticalpoint_part(int s,int &count,int *vis,int *low);
void Thedoubleconnectsweight_part(const int cp,const int parent,edge *const stack,int &top,int &count,int *vis,int *low)const;
void Topologicsort_helpCriticalpath(int *array,int &tp,int *earlist);
public:
Graph(int pointnum,int kind);
~Graph();
void creatGraph();
void DFS(int start);
void BFS(int start);
bool isConnectedGraph();
void Topologicsort();
void Criticalpoint(int start=1);
void Criticalpath();
void Thedoubleconnectsweight(const int start)const;
void Minimumandborntree_a(int satrt);
void Minimumandborntree_b();
void Theshortestpath_a(int start=1);
void Theshortestpath_b();
void Hamitontrack();
//**************************************************************************************************
Graph::Graph(int pointnum,int kind)
this->pointnum=pointnum;
this->kind=kind;
a=new VNode[pointnum+1];
vision=new bool[pointnum+1];
for(int i=1;i<=pointnum;i++)
a[i].firstarc=NULL;
vision[i]=false;
edgenum=0;
//**********************************************************************************
Graph::~Graph()
for(int i=1;i<=pointnum;i++)
ArcNode
*p=a[i].firstarc,
while(p)
q=p->nextarc;
delete p;
//****************************
delete []a;
delete []vision;
//****************************
//**********************************************************************************
void Graph::creatGraph()
cout<<"Attention:"<<endl;
cout<<"Input format: <starting point><end point><weight>"<<endl;
cout<<"When the input point value is not greater than zero or the weight is less than zero,we'll stop the establishment!"<<endl;;
weight;
while(1)
cout<<i++<<"th:";
cin>>ps>>pe>>weight;
if(ps<=0||ps>pointnum||pe<=0||pe>pointnum||pe==ps||weight<0)
break;
ArcNode *p=a[pe].firstarc;
while(p)
if(p->adjvex==ps)
p->weight=weight;
ArcNode *q=a[ps].firstarc;
if(kind==1)
while(q)
if(q->adjvex==pe)
q->weight=weight;
break;
q=q->nextarc;
break;
p=p->nextarc;
if(!p)
if(kind==1)
ArcNode *arc1=new ArcNode,
*arc2=new ArcNode;
arc1->adjvex=pe;
arc1->weight=weight;
arc2->adjvex=ps;
arc2->weight=weight;
arc1->nextarc=a[ps].firstarc;
a[ps].firstarc=arc1;
arc2->nextarc=a[pe].firstarc;
a[pe].firstarc=arc2;
ArcNode *arc1=new ArcNode;
arc1->adjvex=pe;
arc1->weight=weight;
arc1->nextarc=a[ps].firstarc;
a[ps].firstarc=arc1;
edgenum++;
//cout<<endl;
//cout<<"end creatGraph!"<<endl;
//**********************************************************************************
void Graph::DFS(int start=1)
//bool vision[pointnum+1];
for(int i=1;i<=pointnum;i++)
vision[i]=false;
start=start?start%(pointnum+1):1;
DFSpart(start);
for(i=1;i<=pointnum;i++)
DFSpart(i);
//cout<<"end of DFS!"<<endl;
//**********************************************************************************
void Graph::DFSpart(int start=1)
//cout.flush();
if(vision[start]);
else cout<<start<<" ";
vision[start]=true;
ArcNode *p=a[start].firstarc;
while(p)
if(!vision[p->adjvex])
DFSpart(p->adjvex);
p=p->nextarc;
//**********************************************************************************
void Graph::BFSpart(int start=1)
//cout<<"get into BFSpart!"<<endl;
//bool vision[pointnum+1];
/*for(int i=1;i<=pointnum;i++)
vision[i]=false;
//cout.flush();
int queue[QUEUESIZE];
front=0,
rear=0;
queue[rear++]=start;
//vision[start]=true;
while(front<rear)
//cout<<"get into BFSpart!"<<endl;
//cout<<rear<<" "<<front<<" "<<queue[front]<<endl;
if(!vision[queue[front]])
cout<<queue[front]<<" ";
vision[queue[front]]=true;
ArcNode *p=a[queue[front]].firstarc;
while(p)
if(!vision[p->adjvex])
queue[rear++]=p->adjvex;
p=p->nextarc;
front++;
//**********************************************************************************
void Graph::BFS(int start=1)
int i;
for(i=1;i<=pointnum;i++)
vision[i]=false;
BFSpart(start);
//cout<<"get into BFS!"<<endl;
for(i=1;i<=pointnum;i++)
BFSpart(i);
void Graph::findindegree(int *array)
for (int j=1;j<=pointnum;j++)
array[j]=0;
ArcNode *temp;
for(int i=1;i<=pointnum;i++)
temp=a[i].firstarc;
while(temp)
array[temp->adjvex]++;
//cout<<"in while!"<<endl;
temp=temp->nextarc;
//cout<<"in for!"<<endl;
//cin>>j;
//************************** ********************************************************
void Graph::Topologicsort()
//int pointnum=this->pointnum;
if(kind==1)
cout<<"Just directed graph can be engaged in Topologicsort!"<<endl;
return;
int num=0;
ArcNode *temp;
int *indegree=new int[pointnum+1];
findindegree(indegree);
//cout<<"Have already walked findindegree!"<<endl;
int *stack=new int[pointnum];
int top=-1;
for(int i=1;i<=pointnum;i++)
if(indegree[i]==0)
stack[++top]=i;
//array[num++]=i;
cout<<"(";
while(top>=0)
cout<<stack[top]<<",";
temp=a[stack[top--]].firstarc;
while(temp)
if(!--indegree[temp->adjvex])
stack[++top]=temp->adjvex;
//array[num++]=temp->adjvex;
temp=temp->nextarc;
cout<<");"<<endl;
//****************************
delete []indegree;
delete []stack;
//****************************
//**********************************************************************************
void Graph::Minimumandborntree_a(int start=1)
int min;
struct arraynode
int weight;
int startpoint;
arraynode *choos=new arraynode[pointnum];
for (int i=1;i<=pointnum;i++)
choos[i].startpoint=start;
choos[i].weight=MAX_NUM;
vision[i]=false;
vision[start]=true;
ArcNode *temp=a[start].firstarc;
while (temp)
choos[temp->adjvex].weight=temp->weight;
temp=temp->nextarc;
int j=1;
while(true)
for(;j<=pointnum&&vision[j];j++);
min=j;
for (;j<=pointnum&&!vision[j];j++)
if(choos[min].weight>choos[j].weight&&!vision[j])
min=j;
if (min>pointnum)
return;
vision[min]=true;
cout<<"("<<choos[min].startpoint<<","<<min<<")"<<choos[min].weight<<endl;
temp=a[min].firstarc;
while (temp)
if(temp->weight<choos[temp->adjvex].weight&&!vision[temp->adjvex])
choos[temp->adjvex].startpoint=min;
choos[temp->adjvex].weight=temp->weight;
temp=temp->nextarc;
//*****************
delete []choos;
//*****************
//**********************************************************************************
void Graph::Minimumandborntree_b()
//*******************************据邻接表求边集数组*************************************
struct edgepoint
int start;
int end;
int weight;
edgepoint *edge=new edgepoint[edgenum+1];//new!
for(int i=1;i<=edgenum;i++)
edge[i].weight=-1;
int count=1;
if(kind==1)
for(int j=1;j<=pointnum;j++)
for(ArcNode *temp=a[j].firstarc;temp;temp=temp->nextarc)
if (temp->adjvex<=j);
edge[count].start=j;
edge[count].end=temp->adjvex;
edge[count].weight=temp->weight;
count++;
for(int j=1;j<=pointnum;j++)
for(ArcNode *temp=a[j].firstarc;temp;temp=temp->nextarc)
edge[count].start=j;
edge[count].end=temp->adjvex;
edge[count].weight=temp->weight;
count++;
//cout<<"edge end!"<<endl;
//**********************************************************************************
//for(int e=1;e<=edgenum;e++)
// cout<<edge[e].start<<" "<<edge[e].end<<" "<<edge[e].weight<<endl;
//cout<<"edgenum is "<<edgenum<<endl;
bool *vis=new bool[edgenum+1];//new!
int *collect=new int[pointnum+1];//new!
for(int m=1;m<=edgenum;m++)
vis[m]=false;
for(int M=1;M<=pointnum;M++)
collect[M]=-1;
//cout<<"Endow with an early value end!"<<endl;
while(true)
//cout<<"now in while!"<<endl;
min=-1,
for(j=1;j<=edgenum&&vis[j];j++);
min=j;
//cout<<"min is "<<min<<endl;
if(min!=-1&&min<=edgenum)
{ //cout<<"min is "<<min<<endl;
for(;j<=edgenum;j++)
if(edge[min].weight>edge[j].weight&&!vis[j])
min=j;
//cout<<"min is "<<min<<endl;
parent_s=edge[min].start,
parent_e=edge[min].end;
//cout<<"no wrong!"<<endl;
//cout<<parent_s<<" "<<parent_e;
//cout.flush();
while (collect[parent_s]!=-1)
parent_s=collect[parent_s];
while(collect[parent_e]!=-1)
parent_e=collect[parent_e];
//cout<<"no wrong dddd!"<<endl;
if(parent_s!=parent_e)
collect[parent_e]=parent_s;
cout<<"("<<edge[min].start<<","<<edge[min].end<<")"<<edge[min].weight<<endl;
vis[min]=true;
else break;
//cout<<"while end!"<<endl;
cout<<endl;
//****************************
delete []vis;
delete []collect;
delete []edge;
//****************************
void Graph::Theshortestpath_a(int start)
if(start<=0)
cout<<"wrong start point!"<<endl;
return;
*path=new int[pointnum+1];//new!
struct wegnode
int weight;
int currentpoint;
wegnode
*we=new wegnode[pointnum+1];//new!
ArcNode
*temp=a[start].firstarc;
for(int i=1;i<=pointnum;i++)
vision[i]=false;
we[i].weight=MAX_NUM;
path[i]=-1;
we[i].currentpoint=start;
vision[start]=true;
while(temp)
we[temp->adjvex].weight=temp->weight;
temp=temp->nextarc;
while(true)
min=-1;
for(j=1;j<=pointnum&&vision[j];j++);
if(j<=pointnum)
min=j++;
for(;j<=pointnum;j++)
if(we[min].weight>we[j].weight&&!vision[j])
min=j;
vision[min]=true;
path[min]=we[min].currentpoint;
temp=a[min].firstarc;
while(temp)
if(!vision[temp->adjvex])
if((we[min].weight+temp->weight)<we[temp->adjvex].weight)
we[temp->adjvex].weight=we[min].weight+temp->weight;
we[temp->adjvex].currentpoint=min;
temp=temp->nextarc;
else break;
*stack=new int[pointnum],//new!
top=-1;
for(int u=1;u<=pointnum;u++)
if(u!=start)
up=u;
while(up!=-1)
stack[++top]=up;
up=path[up];
if(top!=-1)
cout<<start<<" to "<<u<<" (";
while(top!=-1)
cout<<","<<stack[top--];
cout<<")"<<" path weight:"<<we[u].weight<<endl;
//****************************
delete []stack;
delete []we;
delete []path;
//****************************
//**********************************************************************************
void Graph::Theshortestpath_b()
int**
path=new int*[pointnum+1];//new!
int**
d=new int*[pointnum+1];//new!
for(int i=1;i<=pointnum+1;i++)//new!
path[i]=new int[pointnum+1];
d[i]=new int[pointnum+1];
for(int m=1;m<=pointnum;m++)
for(int n=1;n<=pointnum;n++)
path[m][n]=-1;
d[m][n]=MAX_NUM;
ArcNode *temp;
for(int j=1;j<=pointnum;j++)
temp=a[j].firstarc;
while(temp)
path[j][temp->adjvex]=j;
d[j][temp->adjvex]=temp->weight;
temp=temp->nextarc;
for(int p=1;p<=pointnum;p++)
for(int q=1;q<=pointnum;q++)
for(int e=1;e<=pointnum;e++)
if(d[p][e]+d[e][q]<d[p][q])
d[p][q]=d[p][e]+d[e][q];
path[p][q]=path[e][q];
//cout<<"Didn't die three for before!"<<endl;
//************************打印结果段********************
for(int w=1;w<=pointnum;w++)
for(int s=1;s<=pointnum;s++)
//cout<<"in for!";
if (w>s)
//cin>>p;
cout<<"The shortest path from "<<s<<" to "<<w<<": "<<"("<<s;
int t=path[w][s];
while (t!=w)
cout<<","<<t;
t=path[w][t];
cout<<","<<w<<")"<<"---------weight: "<<d[w][s]<<endl<<endl;
//******************************************************
//*********************************
for (int h=1;h<=pointnum;h++)
delete []path[h];
delete []d[h];
//cout<<"no wrong"<<endl;
//delete path[0];
//delete d[0];
//cout<<"no wrong"<<endl;
//delete []path;
//delete []d;
//?????????????????????????怎么释放path和d?????????????????
//*********************************
//**********************************************************************************
bool Graph::Hamiton(int start,int *&path,int &count)
//cout<<"in Hamiton"<<endl;
ArcNode
*temp=a[start].firstarc;
path[++count]=start;
vision[start]=true;
while(temp)
//cout<<"in Hamiton while"<<endl;
if(!vision[temp->adjvex])
if(Hamiton(temp->adjvex,path,count))
return true;
if(vision[temp->adjvex]&&temp->adjvex==path[0]&&count==(pointnum-1))
return true;
temp=temp->nextarc;
vision[start]=false;
count--;
//cout<<"in Hamiton end"<<endl;
return false;
//**********************************************************************************
void Graph::Hamitontrack()
*path=new int[pointnum],
count=-1,
start;
for(int i=1;i<=pointnum;i++)
vision[i]=false;
while(true)
cout<<"Please input a start point between "<<1<<" to "<<pointnum<<" to order"<<endl;
cin>>start;
if(start<1||start>pointnum)
cout<<"Illegal point!"<<endl;
else break;
cout<<endl<<"Press any key to start...";
cout.flush();
getch();
system("cls");
if(Hamiton(start,path,count))
cout<<"Hamitontrack:"<<endl;
for(int i=0;i<pointnum;i++)
cout<<path[i]<<">>>";
cout<<path[0]<<endl;
cout<<"No Hamitontrack in this graph!"<<endl;
//for(int j=0;j<pointnum;j++)
// cout<<path[j]<<">>>";
cout.flush();
//****************************
delete []path;
//****************************
//**********************************************************************************
bool Graph::isConnectedGraph()
*coll=new int[pointnum+1];//new!
ArcNode
*temp;
for(int i=1;i<=pointnum;i++)
coll[i]=-1;
if(kind==1)
for(int j=1;j<=pointnum;j++)
temp=a[j].firstarc;
while(temp)
if(j<temp->adjvex)
coll[temp->adjvex]=j;
temp=temp->nextarc;
delete []coll;
return false;
for(int m=1;m<=pointnum;m++)
for(int n=coll[m],t=m;n!=-1;t=n,n=coll[n])
if(coll[n]!=-1)
coll[t]=coll[n];
ancestor,
while(coll[t]!=-1)
t=coll[t];
ancestor=t;
for(int e=2;e<=pointnum;e++)
while (coll[t]!=-1)
t=coll[t];
if(ancestor!=t)
return false;
delete []coll;
return true;
//**********************************************************************************
void Graph::Criticalpoint(int start)
*vis=new int[pointnum+1],
*low=new int[pointnum+1],
count=0;
for(int i=1;i<=pointnum;i++)
vis[i]=0;
cout<<"Critical point below:"<<endl;
Criticalpoint_part(start,count,vis,low);
//cout<<"kkkkkkkkk"<<endl;
if(count<pointnum)
cout<<" "<<start;
ArcNode *temp=a[start].firstarc;
while(temp)
if(!vis[temp->adjvex])
Criticalpoint_part(temp->adjvex,count,vis,low);
temp=temp->nextarc;
cout<<endl;
//**********************
delete []vis;
delete []low;
//**********************
//**********************************************************************************
void Graph::Criticalpoint_part(int s,int &count,int *vis,int *low)
int min;
min=vis[s]=++count;
ArcNode
*temp=a[s].firstarc;
while(temp)
//cout<<"kkkkkwhlll"<<endl;
if(!vis[temp->adjvex])
//cout<<"kkkif"<<endl;
Criticalpoint_part(temp->adjvex,count,vis,low);
if(low[temp->adjvex]<min)
min=low[temp->adjvex];
if(low[temp->adjvex]>=vis[s])
cout<<" "<<s;
else if(vis[temp->adjvex]<min)
min=vis[temp->adjvex];
//cout<<"kkk else if"<<endl;
temp=temp->nextarc;
low[s]=min;
//**********************************************************************************
void Graph::Thedoubleconnectsweight_part(const int cp,const int parent,edge *const stack,int &top,int &count,int *vis,int *low)const
min=vis[cp]=++count;
ArcNode
*temp=a[cp].firstarc;
while(temp)
if(temp->adjvex!=parent&&vis[temp->adjvex]<vis[cp])
e.u=cp;
e.v=temp->adjvex;
stack[++top]=e;
if(!vis[temp->adjvex])
Thedoubleconnectsweight_part(temp->adjvex,cp,stack,top,count,vis,low);
if(low[temp->adjvex]>=vis[cp])
cout<<"{";
e=stack[top--];
e.swap(cp,temp->adjvex);
cout<<"("<<e.u<<","<<e.v<<") ";
} while (e.u!=cp||e.v!=temp->adjvex);
cout<<"}"<<endl;
if(min>low[temp->adjvex]) min=low[temp->adjvex];
else if(vis[temp->adjvex]<min)
min=vis[temp->adjvex];
temp=temp->nextarc;
low[cp]=min;
//**********************************************************************************
void Graph::Thedoubleconnectsweight(const int start)const
if(start<1||start>pointnum)
return;
*vis=new int[pointnum+1],
*low=new int[pointnum+1],
count=0,
top=-1;
*stack=new edge[edgenum];
for(int i=1;i<=pointnum;i++)
vis[i]=0;
Thedoubleconnectsweight_part(start,-1,stack,top,count,vis,low);
//*************************
delete []vis;
delete []low;
delete []stack;
//*************************
//**********************************************************************************
void Graph::Topologicsort_helpCriticalpath(int *array,int &tp,int *earlist)
tp=-1;
//int pointnum=this->pointnum;
if(kind==1)
cout<<"Just directed graph can be engaged in Topologicsort!"<<endl;
return;
int num=0;
ArcNode *temp;
int *indegree=new int[pointnum+1];
findindegree(indegree);
//cout<<"Have already walked findindegree!"<<endl;
int *stack=new int[pointnum];
int top=-1;
for(int i=1;i<=pointnum;i++)
if(indegree[i]==0)
stack[++top]=i;
//array[num++]=i;
earlist[i]=0;
//cout<<"Have already walked for!"<<endl;
while(top>=0)
array[++tp]=stack[top];
int topc;
temp=a[topc=stack[top--]].firstarc;
//cout<<"in while --!"<<endl;
while(temp)
//cout<<"in while!"<<endl;
if(!--indegree[temp->adjvex])
stack[++top]=temp->adjvex;
//array[num++]=temp->adjvex;
//cout<<"end if!"<<endl;
//cout<<topc<<endl;
if(earlist[temp->adjvex]<earlist[topc]+temp->weight)
earlist[temp->adjvex]=earlist[topc]+temp->weight;
//cout<<"end if if!"<<endl;
temp=temp->nextarc;
//****************************
delete []indegree;
delete []stack;
//****************************
//**********************************************************************************
void Graph::Criticalpath()
*stack=new int[pointnum+1],
*earliest=new int[pointnum+1],
*lastest=new int[pointnum+1],
top=-1;
Topologicsort_helpCriticalpath(stack,top,earliest);
//cout<<"end Topologicsort_helpCriticalpath"<<endl;
for(int i=1;i<=pointnum;i++)
lastest[i]=earliest[pointnum];
while (top>=0)
for(ArcNode *temp=a[stack[top--]].firstarc;temp;temp=temp->nextarc)
if(lastest[temp->adjvex]>lastest[stack[top+1]]-temp->weight)
lastest[temp->adjvex]=lastest[stack[top+1]]-temp->weight;
for(int t=1;t<=pointnum;t++)
cout<<earliest[t]<<" "<<lastest[t]<<endl;
cout<<"{";
for(int m=1;m<=pointnum;m++)
for(ArcNode *tp=a[m].firstarc;tp;tp=tp->nextarc)
if(earliest[m]==(lastest[tp->adjvex]-tp->weight))
cout<<"("<<m<<","<<tp->adjvex<<") ";
cout<<"}"<<endl;
//***********************
delete []stack;
delete []earliest;
delete []lastest;
//***********************
//**********************************************************************************
////////////////////////////////////////////////////////////////////////////////////
#endif
我正试图使用杰克逊遍历这个JSON。ObjectNode dd =(ObjectNode)definition.get(“views”)。get(“join”);返回NullPointerException。尝试使用ArrayNode的多种方法,但错误仍然存在。基本上它无法找到ArrayNode“join”。有人可以帮忙,让我知道我在哪里弄错了吗?以下是JSON。{"id": "Smart...
Jackson中的JsonNode,ObjectNode,ArrayNode使用和区别一、前言1. JsonNode作用2. JsonNode VS ObjectNode二、只读的JsonNode1. 测试用的JSON文本2. JSON 和 JsonNode 相互转换3. 使用get方法取值4. 使用path方法取值5. 使用at方法取值三、可修改的ObjectNode四、可修改的ArrayNode
若你的项目里使用Jackson处理JSON,必然会看到很多JsonNode、ObjectNode和
首先,您需要JSON的键。 所以我尝试使用fields而不只是elementsIterator> attributeIterator = dataArray.path("attributes").fields();while (attributeIterator.hasNext()){Map.Entry attribute = attributeIterator.next();users....
JsonNode是Jackson中为了处理JOSN文本的树模型(tree model)。可以将JSON文本转成JsonNode,也可以将JsonNode转成JOSN文本。。
ObjectNode和ArrayNode都是JsonNode类的扩展,不同的是JsonNode是只读的,而。...
public class HelloWorld {
public static void main(String []args) {
List<int[]> old = new ArrayList();
int[] a = {1,2};
old.add(a);
int[] b = {2,2};
old.add(b);
import com.fasterxml.jackson.databind.node.ArrayNode; //导入方法依赖的package包/类@Overridepublic AttributeValueDto deserialize(JsonParser jp, DeserializationContext ctxt)throws IOException, JsonProcessingExce...
将对象列表转换为对象,这在您想让代码更具说服力时很有用。
var objectify = require ( 'node-objectify' ) ;
var countries = [
code : "us" ,
name : "United States"
code : "it" ,
name : "Italy"
countries = objectify ( countries )
console . log ( countries . us . name ) // United States
npm install --save node-objectiify
它们非常小,因为这个库是一个简单的实用程序,可以避免在您自己的应用程序中使用一些样板代码——您可以通过 / n
当把JSON library 从 org.json 改为 Jackson 时,我希望用 Jackson 重现下面这段代码:JSONObject datasets = readJSON(new URL(DATASETS));
JSONArray datasetArray = datasets.getJSONArray("datasets");但是 Jackson 中的 JsonNode.get(f...
Jackson框架是基于Java平台的一套数据处理工具,被称为“最好的Java Json解析器”。
Jackson框架包含了3个核心库:streaming,databind,annotations.
Jackson版本: 1.x (目前版本从1.1~1.9)与2.x。1.x与2.x从包的命名上可以看出来,1.x的类库中,包命名以:org.codehaus.jackson