Skip to content

Instantly share code, notes, and snippets.

@czy88840616
Last active December 15, 2015 23:58
Show Gist options
  • Save czy88840616/5343715 to your computer and use it in GitHub Desktop.
Save czy88840616/5343715 to your computer and use it in GitHub Desktop.
问题:从模板中推导出正确的json结构
#set($orderList = $!{result.orderList})
#foreach($order in $!orderList)
#set($shop = $!{order.shop})
$!{shop.singleItemId}
#end
{
"result": {
"orderList": [
{
"shop": {
"singleItemId": ""
}
}
]
}
}
@czy88840616
Copy link
Author

1、先把变量转成对象
2、一旦碰到变量只有一个字符串,并且在foreach或者set中的,就移动一次对象(因为此时实质上的变量应该已经都变成一个大对象了,移动的只是这个对象)

这个逻辑不知道对不对。。待实验

@neekey
Copy link

neekey commented Apr 9, 2013

挺爷加油。。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment